determine if all values in a list of lists are true or false

You can use list comprehension for this. Iterate the inner lists and extract the second value (True\False). Then use all to check all the values.

x = [['Product 0', False, ], ['Product 1', False, ], ['Product 2', False,]]

AllTrue  = all([e[1] for e in x])      # False
AllFalse = all([not e[1] for e in x])  # True

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top