An iterator tracks progress through a sequence of values and may be exhausted.
Background
Python programs operate on objects through names. These examples refresh practical reasoning about values, state, interfaces, and scientific calculations. Run them in a disposable local environment and inspect the result.
An iterator tracks progress through a sequence of values and may be exhausted.
Work through an example
If values = iter([2, 4, 6]), sum(values) consumes the three items. A second sum(values) is zero because there are no remaining items. The original list would support a new traversal.
Check the reasoning
An iterable can supply an iterator; an iterator supplies successive values. Do not assume a generator can be replayed. Materializing a list may be appropriate for repeated access but changes the memory cost.
Practice independently
Write a two-pass calculation using a generator. Demonstrate the failure, then fix it by either recreating the generator or storing the values and explain the tradeoff.
Write down your prediction before consulting the result or revisiting the passage. Explain which observation supports your answer and which part depends on an assumption. Revise the explanation if the evidence does not fit. A useful study note records both the conclusion and the steps another learner would need to check it.
Reference
For the language or library contract, consult the Python language tutorial.
Continue with the course
Explore the curriculum, preparation, and study format for Python Refresher — Course Articles.
Companion article for Python Refresher — Course Articles. Original commentary and examples © 2026 Choral Software. Source literary works retain their own attribution.
