Lets see we have a list of inetgers name x.
x = [3,3,3,4,4,4,3,3,5,5,6,6,7,8,9,9,9]
Now iterate over this list using differnet loops.
- For loop
#To read all the elements from list
for elem in x:print(elem)
#To read element from specific index using range(startindex, stopindex)
for i in range(2, len(x)):
print(x[i])
- While loop
while i < len(x):print(x[i])i+=1