MemotivaIterators and iterables

What is the difference between an iterable and an iterator?

Iterators and iterables

Audio flashcard · 0:16

Nortren·

What is the difference between an iterable and an iterator?

0:16

An iterable is any object that can return an iterator, by implementing dunder iter. An iterator is an object that produces values one at a time, by implementing both dunder iter and dunder next. Lists and dicts are iterables but not iterators. Calling iter on an iterable returns an iterator.
docs.python.org