iter
Iter is commonly used to refer to the Python built-in function iter, which returns an iterator for a given iterable. There are two forms: iter(iterable) and iter(callable, sentinel). The first creates an iterator from an iterable object by calling its __iter__ method. The second creates an iterator that repeatedly calls a zero-argument function until it returns a sentinel value; when the sentinel is produced, iteration ends.
An iterator implements the iteration protocol by providing __iter__ and __next__ methods. __iter__ returns the iterator
Common iterables include lists, tuples, strings, and dictionaries (which yield keys by default). You obtain an
Notes: The distinction between iterable and iterator is important. An iterable can produce a new iterator each