+ 1

Double asterisk in function parameters

Found this one on challenge: def func(**qwerty): print(qwerty["one"]) func(a=0, one=173) Output--> '173' questions: 1) Why and when are double asterisk used in function arguments? 2) why at line 2 of funtion the qwerty parameter is given as a list[]? thank you in advance for help.

17th Oct 2018, 8:42 AM
Roberto
2 Respuestas
+ 3
With * you are passing a bunch of values in tuple format and can then access them from the function. With ** you pass keyworded values in dictionary format: {'one': 173, 'two': 0,... } And dictionary objects you access by dictname['key'].
17th Oct 2018, 9:16 AM
HonFu
HonFu - avatar
17th Oct 2018, 4:03 PM
Maninder $ingh
Maninder $ingh - avatar