What is the difference between an Iterator and Iterable in Python?

An Iterable is an object that can be iterated by an Iterator.

In Python, Iterator object provides iter() and next() methods.

In Python, an Iterable object has iter function that returns an Iterator object.

When we work on a map or a for loop in Python, we can use next() method to get an Iterable item from the Iterator.


Posted

in

Tags:

Comments

Leave a Reply