0

Dictionaries in python

Why when i print this dict print({True:"yes", 1:"no", 1.0:"maybe"}) I only get {True:"maybe"} Not the whole dictionary??

26th May 2021, 11:24 PM
Alaa Aldeen Shammr
Alaa Aldeen Shammr - avatar
12 Respuestas
+ 4
Yes
28th May 2021, 5:19 PM
::sк::
::sк:: - avatar
+ 2
I guess that python linked all the key together cause all are true keys then picks the last value or most occuring value
26th May 2021, 11:40 PM
Tim Don👨🏾‍💻🤟
Tim Don👨🏾‍💻🤟 - avatar
+ 1
Just try playing with different value u will see that i mean
26th May 2021, 11:41 PM
Tim Don👨🏾‍💻🤟
Tim Don👨🏾‍💻🤟 - avatar
+ 1
Both keys and values
26th May 2021, 11:41 PM
Tim Don👨🏾‍💻🤟
Tim Don👨🏾‍💻🤟 - avatar
+ 1
ᎪᏞᎪ'Ꭺ ᎪᏞᎠᎬᎬΝ ՏᎻᎪᎷᎷᎡ Because in python 1 and 1.0 and True are same it is replacing duplicate keys value. Just print these and see: print (1 == 1.0) #True print (True == 1) #True print (True == 1.0) #True
27th May 2021, 2:22 AM
A͢J
A͢J - avatar
0
Please can i see the code that doing tya
26th May 2021, 11:30 PM
Tim Don👨🏾‍💻🤟
Tim Don👨🏾‍💻🤟 - avatar
26th May 2021, 11:46 PM
Alaa Aldeen Shammr
Alaa Aldeen Shammr - avatar
0
See your keys are being the same,try with different keys
27th May 2021, 1:36 PM
RuntimeERROR
RuntimeERROR - avatar
0
Netha_r2071 It's just one of sololearn challenge questions
27th May 2021, 1:40 PM
Alaa Aldeen Shammr
Alaa Aldeen Shammr - avatar
0
See true,1,1.0,1.000 all mean the same,and if u want to print then the first key value pair will be printed
27th May 2021, 1:42 PM
RuntimeERROR
RuntimeERROR - avatar
- 1
**that
26th May 2021, 11:30 PM
Tim Don👨🏾‍💻🤟
Tim Don👨🏾‍💻🤟 - avatar