What is the difference between an iterator and an iterable?
Model answer
An iterable can produce an iterator when you call iter() (lists, strings, dicts). An iterator has __next__ and gives one item at a time, raising StopIteration at the end. A for loop calls iter() and then next() repeatedly.
Learn this topic
The Python Standard Library: Dates, Counter, Statistics and More in the course Python for Beginners: Learn to Code with Real Projects.
Sign in to add your own answer.