One of the 50 questions in this topic
How much do you know about Python?An iterator is an object that implements the iterator protocol with the methods __iter__() (returns the iterator) and __next__() (returns the next element or throws StopIteration). Iterators allow you to efficiently traverse collections of data without loading all the elements into memory. They are the basis of for loops, comprehensions and functions like map() or filter(). All iterators are iterables, but not all iterables are iterators.