To tell the difference between False
and 0
you may use is
to compare them. False
is a singleton value and always refers to the same object. To compare all the items in a list to make sure they are not False
, try:
all(x is not False for x in a_list)
BTW, Python doesn’t cast anything here: Booleans are a subclass of integers, and False
is literally equal to 0
, no conversion required.