Skip to main content

Difference between iterators and iterables.

Junior Python
Quick Answer Iterable: object you can loop over - has __iter__() returning an iterator. Lists, tuples, strings, dicts are iterables. Iterator: object with __next__() - stateful, remembers position, consumed once. Iterables can create multiple iterators. iter(mylist) creates an iterator from a list. Generators are iterators. For-loop calls iter() then repeatedly calls next() until StopIteration.

Answer

Iterable: implements __iter__().
Iterator: implements __next__().
for-loops use iter() and next() internally.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice