+ 1
Can any explain how it works ?? Ans is 3.
a =[1,3,6,7] print (a[True])
7 Respostas
+ 3
Ravi Kumar Verma
Bhai, By default True and False are associated with Binary,
Where:
False means 0
and
True means 1
So when you used True as index for the list, it automatically used 1 instead of True hence showing you element at Index 1 i.e Value = 3
:) Hope you Got it
Ask ur doubts if u still have any
+ 2
Ravi Kumar Verma true= 1, so a[true]=a[1]
a[0]=1, a[1]=3,a[2]=6 etc.. a[false]=1
+ 2
Kanishk Mewal thanks broo
+ 1
True is equivalent to 1
False is equivalent to 0
a[True] = a[1] = 3
>>> Infinity
- 1
since True == 1