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 Antworten
+ 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