Skip to main content

for loop in Python


Loops are used in programming to repeat a specific block of code on the basis of certain condition. In python for loop is used for run same sequence number of times.

For Loop Syntax Python

for <variable> in <sequence>:  
for <variable> in <sequence>:  

Python for loop example

for i in range (1,6):  
print i

Output

1
2
3
4
5
 

Comments