0
why 1: False in output?
pairs = {1: "apple", "orange": [2, 3, 4], True: False, None: "True", } print(pairs.get("orange")) print(pairs.get(7)) print(pairs.get(12345, "not in dictionary")) pairs [2]=55 print (pairs) output: [2,3,4] None not in dictionary {1:False , 'orange': [2, 3, 4], True: False, None: 'True',2:55}
4 Respostas
+ 4
Look in the comments; it helped me here and I think it'll help you too. ;)
+ 1
IN PYTHON THIS THINGS ARE BY DEFAULT..
1 MEANS TRUE
0 MEANS FALSE
suppose...u doing
pairs={1 : "yoo" , 0 : "solo" ,True : "hi" , False : "bye"}
print(pairs)
{ 1 : "hi" , 0 : "bye" }
taking last values initialised in 1 and 0
as 1 is true and 0 is false
initialising in true and false means reinitialising in 1 and 0
+ 1
### another proof that 1 is True and 0 is False####
try this code
###############
pairs={1 : "qwerty" , 0 : "solo"}
print(pairs.get(True))
print(pairs.get(False))
###############
output--->
qwerty
solo
0
thank you so much👌👌👌