PRACTICE / UNDERSTAND / REPEAT

Python: Iterators & generators

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

20 questionsAnswers explainedFree · no login
Question 1 of 20
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.