4 ms·
I 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.
by georgyo 8y ago
I 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.