Quiz: Iterators and Generators
Test your mastery of the iterator protocol, generator functions, lazy evaluation, and custom iterator classes with these advanced questions.
We'll cover the following...
We'll cover the following...
Technical Quiz
1.
We manually iterate over a list using the iterator protocol. What happens when we call next() on the iterator object after it has returned the last element?
A.
It returns None.
B.
It raises a StopIteration exception.
C.
It resets to the first element and returns it.
D.
It raises an IndexError.
1 / 10
...