Hi i have a list with True False Values,
visited =[True, False, True, False]
I'm not sure if its possible but id like to use list logic in a while loop when the list is empty or visited has no more False values id like to end the While loop Here is my try it seem to be a infinite loop. And i'm unable to change False Values when i come across one here is my code
class mass:
def __init__(self):
visited =[True, False, True, False]
self.x = 0
while len([self.x for self.x, values in enumerate(visited) if visited[self.x] == False ]) > 0:
print(self.x)
visited[self.x] = True
print(visited)
self.x = 0
c = mass()
c
Id like to change the false values as well as stop the loop one the length reaches 0 in the while loop. When i do this in python console i get the output
>>> [x for x, values in enumerate(visited) if visited[x] == False ]
[1, 3]
visited =[True, True, True, True]
Then if i do
>>> visited =[True, True, True, True]
>>> [x for x, values in enumerate(visited) if visited[x] == False ]
[]
so then i tried
>>> print(len([x for x, values in enumerate(visited) if visited[x] == False ]))
0
Which lead me to think i can do
while len([x for x, values in enumerate(visited) if visited[x] == False ]) > 0
Which loops continuously. Any advice would be excellent thank you
Falsevalues in the list?