I have the following question:
>>> a = [200,100]
>>> a[True]
Output >>>
100
>>> a = [200,100]
>>> a[False]
Output >>>
200
Why does this happen? Is the first value false and the second true?
I have the following question:
>>> a = [200,100]
>>> a[True]
Output >>>
100
>>> a = [200,100]
>>> a[False]
Output >>>
200
Why does this happen? Is the first value false and the second true?
This is because false
equals 0 and true
equals 1.
Then it would be the same thing as:
a = [200,100]
a[1]
Output > > > 100
a = [200,100]
a[0]
Output > > > 200
In Python any value other than 0 automatically is true
when you are going to do some logical verification, for example:
(3 == true) //true
(0 == true) //false