How to make an iterator in Python PREMIUM

Trey Hunner smiling in a t-shirt against a yellow wall
Trey Hunner
5 min. read 4 min. video Python 3.8—3.12
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