MemotivaIterators and iterables

What is StopIteration?

Iterators and iterables

Audio flashcard · 0:15

Nortren·

What is StopIteration?

0:15

StopIteration is the exception raised by an iterator's next method to signal that there are no more values. The for loop catches it automatically. Manually iterating with next can let you handle StopIteration explicitly. Inside generators, returning from the function raises StopIteration implicitly.
docs.python.org