PYTHON Dictionary problem | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

PYTHON Dictionary problem

dict={1:"one",2:"two",True:False,None:"True"} print(dict[1]) This code prints "False" why?????? this should be "one"

11th Apr 2019, 7:19 AM
Tharindu EpaZingha
Tharindu EpaZingha - avatar
1 Answer
+ 7
Cuz 1 and True are same thing...And the latter entry overrides the former https://code.sololearn.com/cNBMv4WTIaui/?ref=app See this if you ask python 1==True Output is True.... So 1 and True are samething
11th Apr 2019, 7:38 AM
Saksham Jain
Saksham Jain - avatar