How can you make a sequence in Python?
Sequences in Python are objects that can be looped over, can be indexed and have a length:
So to make our own sequences, we need to make a class with instances that are iterable, indexable, and work with the built-in len
function:
...
This is a premium screencast available only to active Python Morsels subscribers.
Feel free to watch some of the free screencasts in the Dunder Methods series.
Need to fill-in gaps in your Python skills? I send weekly emails designed to do just that.