iterator pattern firstwe define an interface that defines function that gets the next item in the collectionand another function to alert some external function that there are no more elements left in the collection to return secondwe define some sort of object that can use the interface to traverse the collection this object is called an iterator following the traditional approachwe can implement this idea as followsclassic_iter py import abc class iterator(metaclass=abc abcmeta)@abc abstractmethod def has_next(self)pass @abc abstractmethod def next(self)pass class container(metaclass=abc abcmeta)@abc abstractmethod def getiterator(self)pass class mylistiterator(iterator)def __init__(selfmy_list)self index self list my_list list def has_next(self)return self index len(self listdef next(self)self index + return self list[self index class mylist(container)def __init__(self*args)self list list(args