Possible Duplicate:
strange while statement behaviour?
Given the following, how may I implement list comprehension correctly, exit the loop & run the statements after ‘else’? I had tried to scan for ‘-‘ characters but it does not work.
Have tried:
while(current != randomValue)
Trying now:
randomKey = random.choice(list(topic.keys()))
randomValue = random.choice(topic[randomKey])
current = "-" * len(randomValue)
while (i for i in range (0, len(current)) if i != "-"):
(statements)
else:
(statements)
Your test doesn’t make sense — Bool on a generator is always
True:Also
iwill never == ‘-'since you’re looping overrange. I’m not really sure what you’re trying here, but we really can’t help you solve this unless we see you can manage to boil your actual code down to the minimum important portion. (And who knows, by doing that, you might find the problem yourself)