StopIteration
The exception an iterator raises from next() to say it has no more items.
In more detail
A for loop catches it quietly and ends, so you only see it when calling next() by hand past the end. Inside a generator, just return or reach the end instead of raising it.
Related terms
- exception — An error object a program raises to stop normal flow and report that something went wrong.
- traceback — The report Python prints when an unhandled exception stops a program, listing the chain of calls that led there and ending with the error.
Taught in
- Iterators And Generators — Hands-on Python: Complete Video Course & Book
- Generators And Iterators — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep