+ 1

In Dictionaries in Pyhon, key value 1 and 0 will create confusion if another key values are "True" or "False"

pairs = {1: "apple", "orange": [2, 3, 4], False: True, True: False, #None: "True", } print(pairs.get(1)) #here output will be "false" insted of "apple"

4th Mar 2017, 7:10 PM
Akshay Dhotre
Akshay Dhotre - avatar
1 Resposta
0
Yeah that will happen... But using boolean expressions as keys is rare, and of course not appreciable
4th Mar 2017, 7:26 PM
vishnu
vishnu - avatar