Python for loop example

Python for loop is used to iterate the iterator, iterator could be list, set, tuple etc. Below we will see Python for loop example. See this post Python for loop  for detail about for loop

 

Python for loop with list

 

#Python for loop example with list

number=[1,2,3,4,5,6,7,8,9,10]

for x in number :
    print (x)

 

1
2
3
4
5
6
7
8
9
10

 

Python for loop is very easy to use.  Above is Python loop example with list. To use loop, for keyword is used.

 

Python for loop with tuple

 

#Python for loop example with tuple

number=(1,2,3,4,5,6,7,8,9,10)

for x in number :
    print (x)

 

1
2
3
4
5
6
7
8
9
10

 

 

Please follow and like us:
READ  Find Square root of a number in Python