Iterators and generators

What does list(g) contain?

Examples

Worked example

Input
g = iter([4, 9]); next(g); list(g)
Expected output
[9]

Hints and solution

Hint 1

Write down the starting state and walk through one example by hand.

Reveal worked answer

Calling next already consumed 4. The list loop collects only the remaining 9.

Back to the lesson