Check if the value is true:
if a: pass
To check if a value is invalid:
if not a: pass
However, not a: there is True (and true) for values ​​other than False , for example. None , 0 and empty containers.
If you want to check if the value is True or False (although you usually don’t), try:
if a is True: pass
or
if a is False: pass
Edit: to check the value True or False it seems that you should use if isinstance(a, bool) and a and if isinstance(a, bool) and not a
source share