Python Forum
python dictionary is that a bug ? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: python dictionary is that a bug ? (/thread-40802.html)



python dictionary is that a bug ? - rmangla - Sep-27-2023

"PLEASE IGNORE THIS POST....I MADE A MISTAKE I CAUGHT MY OWN ERROR"

I created below dictionary and then printed values for all the keys

d={0:0,1:1,2:2}

print(d[0])
print(d[1])
print(d[2])

Strangely i get following outputs
0
True (if this is correct then why for 0 it did not give as False)
2


RE: python dictionary is that a bug ? - Gribouillis - Sep-27-2023

I can't reproduce the bug
>>> d={0:0,1:1,2:2}
>>> 
>>> print(d[0])
0
>>> print(d[1])
1
>>> print(d[2])
2
>>> 
I don't think this bug is possible at all. What is your OS, python interpreter, etc? And make sure you post the exact code that was ran, with the exact output.


RE: python dictionary is that a bug ? - DPaul - Sep-27-2023

(Sep-27-2023, 04:34 AM)Gribouillis Wrote: I can't reproduce the bug
Works as it should, no problems (Win 11, python 3.11.2, idle)
Paul