2 ms·
>Rather than checking an index to see if the loop has reached the end of an iterator, the iterator just raises a StopIteration exception and the runtime catches
by layoutIfNeeded 6y ago
>Rather than checking an index to see if the loop has reached the end of an iterator, the iterator just raises a StopIteration exception and the runtime catches it.
And how does the iterator know that it should raise an exception? A conditional.