0

Why 3rd line gives output False??

pairs = {1: "apple", "orange": [2, 3, 4], True: False, None: "True", } print(pairs.get("orange")) print(pairs.get(7)) print(pairs.get(1)) Output: [2,3,4] None False

6th Nov 2019, 2:34 PM
Rameshwar Shende
Rameshwar Shende - avatar
2 Antworten
+ 1
print(pairs) # {1: False, 'orange': [2, 3, 4], None: 'True'} You see, `True` is considered as `1` when you use it as a key. So `1: "apple"` is overrided. And you got `False`.
6th Nov 2019, 4:22 PM
o.gak
o.gak - avatar
0
Thanks
7th Nov 2019, 3:37 AM
Rameshwar Shende
Rameshwar Shende - avatar