PRACTICE / UNDERSTAND / REPEAT

Python practice question

Practice iterators & generators with self-contained questions. Check your answer, then use the explanation to understand the reasoning.

1 questionAnswers explainedFree · no login

Try this question

Iterators & generators · MCQQuestion link ↗

What does the second next call return?

values = (x for x in range(1, 4))
next(values)
print(next(values))
Choose one answer
Answer & explanation

Answer: 2

Each next resumes the generator and yields the next item in its range.