A for loop is used for iterating over a sequence like list, tuple, set.
loop is used to run the set of instruction again an again upto specified range
for loop are of two type in python-
- run according to range
- run on sequence(list,tuple,set)
#simple for loop
for i in range(4):
#for each loop
for i in l:
- In this program, there are two loop, first loop is simple for loop which run on range value starting from 0 to 3 while second for loop is a special kind of loop which run in list, and it run and select one by one item and print them.