When I run the following code, I get an error, why is that? Isn't the order of the arguments correct?
def f(a, b, c, d):
print a, b, c, d
f(1, b=2, *(3,), **{'d': 4})
This is the error that I'm getting:
Traceback (most recent call last):
File "/home/asad/scripts/l.py", line 9, in <module>
f(1, b=2, *(3,), **{'d': 4})
TypeError: f() got multiple values for keyword argument 'b'
[Finished in 0.1s with exit code 1]
b=2
in the function call is not a variable assignment but a passing of a keyword argument.
You are passing b
as a keyword argument yet you're also passing the value 3
(as the second positional argument), which is also b
.
So b
is receiving multiple values in that function call.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With