0

Since 0 == False how do you check for a boolean in a list like this:

a = [4, 5, 3, 0, 9, False]

Normally I'd go like this:

if False in a:
   return 'yes'

but the fact that in computer science 0 == False make this:

if False in [4, 5, 3, 0, 9]:
    return 'yes'

return yes as well. How do I check for boolean per-se in a list ?

mr_incredible
  • 837
  • 2
  • 8
  • 21

1 Answers1

-2

You could try something like:

def contains_false(array: list):
    for item in array:
        if isinstance(item, bool) and not item:
            return 'yes'

    return 'no'