0

In Python, if statement recognizes 1, '1', and 2 same. But, 1==True is True, and 2==True and '1'==True are False. Calculations with True calculates True as 1 too.

like this

>>> True+1
2
>>> True-1
0
>>> True/2
0.5
>>> True*2
2

What is the difference between 1 and True in Python? Is True same with 1?

0 Answers0