0
I don't konw why False as this case
hi i am not good english i have a question. i think result of next code is 'apple'. but result is False please answer why. pairs = { 1: "apple","orange": [2, 3, 4], True: False, None: "True",} print(pairs.get(1)) print(pairs[1])
3 Respostas
+ 6
In python there no real boolean values True and False. So, 1 and True are totally same, and your litteral dict declaration override the value of '1' key by the value of 'True' key ^^
On the other hand, the string "1" is different of the integer '1', so you can make distinct keys with string and number...
0
it is taking 1 as boolean true. so maybe typecasting it into an integer might help.
0
think you! very much.^^