How does this work? pairs = {1: "apple", "orange": [2, 3, 4], True: False, None: "True", } print(pairs.get("orange")) print(pairs.get(1)) print(pairs.get(12345, "not in dictionary")) the output is [2, 3, 4] False not in dictionary | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How does this work? pairs = {1: "apple", "orange": [2, 3, 4], True: False, None: "True", } print(pairs.get("orange")) print(pairs.get(1)) print(pairs.get(12345, "not in dictionary")) the output is [2, 3, 4] False not in dictionary

2nd Jan 2017, 4:25 AM
insulator02
4 Answers
+ 1
thank u
2nd Jan 2017, 2:44 PM
insulator02
0
thats because true is also 1. if you erase true=false then at print(pairs.get(1)) the output will be "apple".
2nd Jan 2017, 2:31 PM
Angel Our
Angel Our - avatar
0
how could I do when I want to keep all the element?
2nd Jan 2017, 2:32 PM
insulator02
0
try put 2: "apple" and then print(pairs.get(2))
2nd Jan 2017, 2:34 PM
Angel Our
Angel Our - avatar