When i run this code
def func(x, y, *w, **z):
print x
print y
if w:
print w
if z:
print z
else:
print "None"
func(10,20, 1,2,3,{'k':'a'})
I get the result as follows.
10
twenty
(1, 2, 3, {'k': 'a'})
None
But I expected the following: I mean the list parameters (1,2,3) corresponding to * w and the dictionary correspondence ** z.
10
twenty
(1,2,3)
{'k': 'a'}
Q: What went wrong? How to pass a list and dictionary as parameters?
Added
func(10,20, 10,20,30, k='a')
seems to work
source
share