The / symbol is used to make parameters positional-only.
We must pass values based on their position. We cannot use keyword arguments.
Example:
def calculate(a, b, /):
print(a + b)
calculate(10, 20)
Output:
30
Here:
/ is a positional-only separator.
We must pass arguments by position.
calculate(a=10, b=20)
This gives a TypeError because keyword arguments are not allowed for these parameters.
Top comments (0)