Printing dictionary python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Printing dictionary python

Why is the output of print({True:'yes',1:'no'}) This? {True: 'no'}

26th Nov 2022, 1:58 PM
Edward Finkelstein
Edward Finkelstein - avatar
1 Answer
+ 6
There cannot be two keys in the dictionary with the same name, and since "True" and 1 the same thing, it overwrites its value with "no". https://code.sololearn.com/c30QE5TkR1VG/?ref=app
26th Nov 2022, 2:10 PM
Solo
Solo - avatar