3 ms·
You understand that it can be a confusing code construct though, right? Even in your comments I'm kind of confused at your meaning because you said: > When the
by Nition 8y ago
You understand that it can be a confusing code construct though, right? Even in your comments I'm kind of confused at your meaning because you said:
> When the condition is false, it breaks.
And then you said:
> If the for loop exits normally, the condition was false.
- georgyo 8y agoI have updated that comment, a normal loop exit is not the same as a break. I can understand how it can be confusing, but the inverse would not make any sense. Another way to look at a for loop is a fancy while loop that sets a variable by some function. Every loop iteration that function is ran. If the function fails, the loop exits. This is infact how they work. https://anandology.com/python-practice-book/iterators.html#the-iteration-protocol https://anandology.com/python-practice-book/iterators.html#t... If next() fails, that is when the loop exits.