[dgplug-users] Need Help in understanding the Error Message
Pabitra Pati
pabitrakumarpati at gmail.com
Mon Feb 27 01:37:00 PST 2017
Hi All,
I want to understand the error message I am getting.
Below is my code piece :-
def total(name, *args):
if args:
print("%s has total money of Rs %d/- " %(name, sum(args)))
else:
print("%s's piggy bank has no money" %name)
I can call this method passing the extra arguments inside *().
I know the correct way of passing the arguments. But, I am passing value
for 'name' in form of param=value, *intentionally*, so that it throws me
error. However, I am unable to understand the below error message :-
>>> total(name="Adi", *(1, 2, 10) )
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: total() got multiple values for keyword argument 'name'
How Python is evaluating the above call, that it's getting multiple values
for the parameter 'name'?
Any help is appreciated.
*Thanks,*
*Pabitra*
More information about the Users
mailing list