4 ms·
That means we must have the 'some_condition' variable outside of the loop. I'm not sure what you mean by that, this works just fine. Though you would probably
by dec0dedab0de 13y ago
That means we must have the 'some_condition' variable outside of the loop.
I'm not sure what you mean by that, this works just fine. Though you would probably use range in the real world.
i=0
while i !=5:
i+=1
Instead of
i=0
while True:
i+=1
if i == 5:
break
- klapinat0r 13y agoHe means the variable used in the condition to break (or start/not start), i.e. "i" in your example - which you have outside of your loop.
- dec0dedab0de 13y agoOK, that makes sense then. I was thinking "the condition" was the variable changing within the loop.