Passing list and dictionary type parameter with Python
- by prosseek
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
20
(1, 2, 3, {'k': 'a'})
None
But, I expected as follows, I mean the list parameters (1,2,3) matching *w, and dictionary matching **z.
10
20
(1,2,3)
{'k':'a'}
Q : What went wrong? How can I pass the list and dictionary as parameters?
Added
func(10,20, 10,20,30, k='a')
seems to be working