Answer
An iterator follows the iterator protocol; a generator is a convenient kind of iterator. • Every generator is an iterator. • A custom iterator class implements __iter__ and __next__. • A generator function automatically creates the iterator machinery and preserves local state.
💡 Simple Example
generator = (number * 2 for number in range(3))
print(next(generator))
Output
0
⚡ Quick Revision
Generators are iterators created with generator syntax.