+ 1

How to use both args and kwargs simultaneously?

def my_func(x,y=4, *z, **num): print (x) print (y) print(z) print(num) my_func(2, 3, 4, 5, c=6, a=7, b=8) Expected Output my_func(2, 3, 4, 5, c=6, a=7, b=8)

26th Jun 2021, 11:43 AM
Zahed Shaikh
Zahed Shaikh - avatar
1 Respuesta
0
https://code.sololearn.com/c502xENALnyp/?ref=app z is a tuple and num is a dictionary, they should be treated as such to get expected output. That code would print: 2 3 (4, 5) {'c': 6, 'a': 7, 'b': 8} .
26th Jun 2021, 11:55 AM
Slick
Slick - avatar