Reputation: 768
[Python 3.7]
I want to run a while()
condition which looks at the 3rd
position of all lists in a nested list:
example:
list = [[0,2,3,4], [4,3,2,5], [3,4,3,2]]
while list[:][2] != 2: # ':' denoting all (I know its not correct)
pass # AKA do something
I want to do this because in the code I am working on I have parts of a list that require deletion and I need to know when only a specific element is left.
Upvotes: 1
Views: 50
Reputation: 914
For example:
while all((row[2] != 2 for row in list)):
or:
while any((row[2] != 2 for row in list)):
depending on what you really want.
Upvotes: 2