how can I print **dict | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
4th May 2021, 9:10 AM
Oma Falk
Oma Falk - avatar
2 Answers
+ 4
In order to use **dict with print function you will need to know, what parameter names the print function is using. Passing dict d: d = {"a": 1, "b": 4, "c": 9} to function f: def f(a, b, c): return a + b + c f(**d) equals: f(a = 1, b = 4, c = 9) which in this case equals: f(1, 4, 9) and you would get 13 as result.
4th May 2021, 9:45 AM
Seb TheS
Seb TheS - avatar
0
Seb TheS not what I expected but finally what I wanted. Thanks
4th May 2021, 11:22 AM
Oma Falk
Oma Falk - avatar