In the Python console:
>>> a = 0
>>> if a:
... print \"L\"
...
>>> a = 1
>>> if a:
... print \"L\"
...
L
>>&g
First of all, everything in python is an object. Therefore, your 0 is also an object, specifically, a built-in object.
Here are the built-in objects considered as false:
So when you put 0 in an if or while condition, or in a Boolean operation, it is tested for truth value.
# call the __bool__ method of 0
>>> print((0).__bool__())
False
#
>>> if not 0:
... print('if not 0 is evaluated as True')
'if not 0 is evaluated as True'