Iterables in Python | Python Programming

Iterables in Python: To understand what Iterables in Python, Let’s take an example of list. When we have to read all the elements or items of a list one by one we use some loops (for loop). Reading of elements of list is called iteration.

In simple language, all those objects of python capable of returning its members, one member at a time are called iterables. Some Examples of Iterables in Python are: lists, sets, dictionary, tuples etc.

#Iterables examples
thelist = [1,2,3,4]
for i in thelist:
    print(i)

Output:

#Output
1
2
3
4

Iterables are very useful as we can store them in memory as much as we want but at some extent only. 

Many people remain confused between the terms Iterators, Iterables and Iteration.

1). Iterables: All objects of python capable of returning its element one at a time are called iterables. Ex: list, tuples etc.

2). Iterators: Functions used to iterate over the iterables ( lists, tuples etc.) are called Iterators. Ex: for loop.

3). Iteration: The process of iterating on iterables are called iteration. Ex: execution of for loop over list to access all elements of list one by one.