How to make an iterator in Python PREMIUM

Trey Hunner smiling in a t-shirt against a yellow wall
Trey Hunner
5 minute read Python 3.7—3.10
Python Morsels
Watch as video
03:45

How you can make your own iterator objects in Python?

Iterators need to work with iter and next

An iterable is an object that can be passed to the built-in iter function to get an iterator from it:

...

A Python Tip Every Week

Need to fill-in gaps in your Python skills? I send weekly emails designed to do just that.

Python Morsels
Watch as video
03:45