The result is 0? why? I think it should be 3
tupleTest = (1,5,‘gg’,True,‘kk’,False)
print(tupleTest.index(True))
tupleTest = (1,5,‘gg’,True,‘kk’,False)
print(tupleTest.index(True))
tuple.index()
finds the first element equal to to argument you provided.
>>> 1 == True
True
That’s because booleans are a subtype of integers.
>>> bool.mro()
[<class 'bool'>, <class 'int'>, <class 'object'>]
>>> True + 1
2
>>> 1 == True
True