how to use for loop to print list in python code example

Example 1: python for loop with array

foo = ['foo', 'bar']
for i in foo:
  print(i) #outputs 'foo' then 'bar'
for i in range(len(foo)):
  print(foo[i]) #outputs 'foo' then 'bar'
i = 0
while i < len(foo):
  print(foo[i]) #outputs 'foo' then 'bar'

Example 2: print all elements in list python

# using for loop
scores = [11, 12, 13, 14, 15, 16]
for score in scores:
    print(score)

Example 3: python iterate list

lst = [12, 123, 1234, 12345]
for i in lst:
  print(i)
**********************result*********************
12
123
1234
12345