+ 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.
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'].
+ 3
check this link here is full explanation.
https://stackoverflow.com/questions/36901/what-does-double-star-asterisk-and-star-asterisk-do-for-parameters