Iterators in Python

Learn how to build an iterator.

In the previous lesson, we pondered over the decency of the for loop. Now let’s unveil it and see the magic behind it.

What is an iterator?

In Python, an iterator is an object that implements the __iter__ and __next__ dunder methods.

⚙️ Note: Dunder methods are methods having two prefix and suffix underscores in the method name. They are also known as ...