+ 1
The error says 'non-default argument follows default argument'
def f(x,y,z='spam',a): print(z) f(1,2,'hello',5)
6 Answers
+ 5
Yes 'cause you can't have non-default args after defaults.
def(x,y,a, z='spam'):
print(z)
is the correct way.
+ 2
From the error, I would assume that you should keep all parameters for your function with a default value at the end as to avoid raising the error again.
It should be something like this:
def f(x,y,a,z="spam"):
# Code
+ 2
def f(x,y,a,z='spam'):
print(z)
f(1,2,5,'hello')
+ 1
Thanks Vasiliy
0
Thanks M.Watney
0
Thanks Faisal