+ 3

pairs = {1: "apple", "orange": [2, 3, 4], True: False, None: "True", }

Print(pairs.get(1)) Mustn't this result in => apple??? 🤔

23rd Jun 2019, 7:38 AM
Sanduni Ayesha
Sanduni Ayesha - avatar
2 Respuestas
+ 5
No, because then you also used True, and that evaluates to 1, so it will get that instead
23rd Jun 2019, 7:50 AM
Airree
Airree - avatar
+ 7
0 and 1 should not been used as key in dicts. You can use '0' and '1' instead.
23rd Jun 2019, 9:30 AM
Lothar
Lothar - avatar