In this chapter let us create two examples to demonstrate to you the use of Python for loop.
Print out the elements within a Python list using python for loop.
a = [1,2,3,4,5,6] # a list consists of 6 elements for number in a: print(number)
1 2 3 4 5 6
Print out the numbers from 3 to 13 but not include 13 in it.
for number in range(3,13): print(number)
3 4 5 6 7 8 9 10 11 12
Both for and while loops are constantly been used in Python thus you will see more of them later in this coming tutorial!