Iterators in #Python are usually defined as needing the following two methods:
๐ __iter__ - provides iteration support
๐ __next__ - returns the next item in the container
๐งต๐๐
A #Python list isn't considered an iterator. It is an iterable, something that you iterate over. But because lists don't define `__next__`, they aren't technically an iterator.
However, you can turn a list into an iterator using the built-in `iter()` function:
You can create your own iterators in #Python by adding the appropriate magic methods to your class.
Here is an example:
If you'd like to learn more about Python iterators or generators, check out my tutorial: