Check if any item in Python list is None (but include zero)

For list objects can simply use a membership test:

None in list_1

Like any(), the membership test on a list will scan all elements but short-circuit by returning as soon as a match is found.

any() returns True or False, never None, so your any(list_1) is None test is certainly not going anywhere. You’d have to pass in a generator expression for any() to iterate over, instead:

any(elem is None for elem in list_1)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)