Iterators vs Iterables

Learn to differentiate between iterators and iterables in Python.

Iterators also support iter

The previous description of for loops leaves us with a potential problem. The map function returns an iterator, but we need an iterable to use in the case of a for loop. We can loop over a map, as shown below.

Get hands-on with 1200+ tech skills courses.