What is an iterator and an iterable object?
Answer
•Iterable — something you can loop over with for.
•Iterator — object with __iter__ and __next__.
•iter(obj) returns an iterator.
•next(it) gives the next element or raises StopIteration.
•Generators are iterators.
Was this answer helpful?