3 ms·
The way that an iterator signals that it is done iterating is by raising StopIteration ( https://docs.python.org/3/library/exceptions.html#StopIteration https:/
by Scarblac 3y ago
The way that an iterator signals that it is done iterating is by raising StopIteration ( https://docs.python.org/3/library/exceptions.html#StopIteration https://docs.python.org/3/library/exceptions.html#StopIterat... ).
I don't know if it's still the case in Python 3, but in 2 that exception was core to how for loops and list comprehensions worked.
- ok123456 3y agoThis is still the case.