To create an iterator we have to add the __iter__ and __next__ methods in our class. __iter__ is used to initialize the iterator object and __next__ is used to return the next value from the iterator.
To create an iterator instance we have to call the iter() function on the object of the class.