My question is quite similar to How to check if all elements of a list matches a condition. But I couldn't find a right way to do the same thing in a for loop. For example, using all in python is like:
>>> items = [[1, 2, 0], [1, 0, 1], [1, 2, 0]]
>>> all(item[2] == 0 for item in items)
False
But when I want to use the similar method to check all elements in a for loop like this
>>> for item in items:
>>> if item[2] == 0:
>>> do sth
>>> elif all(item[1] != 0)
>>> do sth
The "all" expression cannot be used in here. Is there any possible way like "elif all(item[2] == 0)" to be used here. And how to check if all elements in list match a condition in a for loop?