Print
Check
https://peps.python.org/pep-0285/
x
to check what your dict looks likex = {0:"value 0", 1:"value 1", 2:"value 2", True:False} print(x)
Output:{0: 'value 0', 1: False, 2: 'value 2'}
TLTR: Key True
is same as 1
thus last seen wins.Check
https://peps.python.org/pep-0285/
Quote:Thebool
type would be a straightforward subtype (in C) of theint
type, and the valuesFalse
andTrue
would behave like0
and1
in most respects (for example,False==0
andTrue==1
would be true) exceptrepr()
andstr()
.
Quote:6. Should bool inherit from int?
=> Yes.
In an ideal world, bool might be better implemented as a separate integer type that knows how to perform mixed-mode arithmetic. However, inheriting bool from int eases the implementation enormously (in part since all C code that calls PyInt_Check() will continue to work – this returns true for subclasses of int). Also, I believe this is right in terms of substitutability: code that requires an int can be fed a bool and it will behave the same as 0 or 1. Code that requires a bool may not work when it is given an int; for example, 3 & 4 is 0, but both 3 and 4 are true when considered as truth values.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs