We offen use loop statements for repeating statements. One of that statement is **for loop**.

Here is the syntax of for loop:

1 2 3 4 |
for <variable> in <sequence>: <statements> else: <statements> |

**Offen use:**

1 2 |
for i in range(start,finish <,step>): print(i) |

**Simple example:**

1 2 3 4 5 |
fruits = ["banana", "orange","strawberry","lemon"] for fruit in fruits: print("Great, delicious " + fruit) else: print("finally fruits is over :)") |

## Python “For Loop” Examples

**Example 1:** Program to list numbers that are fully divisible from 1 to 100 by 3 or 5

1 2 3 |
for i in range(1,101): if i%3==0 or i%5==0: print(i) |

**Example 2:** Program to list 100 from the number entered by the user

1 2 3 4 5 6 |
#www.python-examples.com firstNumber =int(input("Enter a number under 100. Input start number:")); for i in range(firstNumber,100): print(i) |

**Example 3:** Program the sum of the numbers between two numbers according to the specified step

1 2 3 4 5 6 7 8 |
#www.python-examples.com firstNumber =int(input("Input start number:")); secondNumber=int(input("Input finish number:")); stepNumber =int(input("Input step number:")); for i in range(firstNumber,secondNumber,stepNumber): print(i) |

**Example 4:** Calculate exponent of a number without using math.pow method in Python

1 2 3 4 5 6 7 8 9 10 |
#www.python-examples.com baseNumber =int(input("Enter base nummber:")); exponentNumber =int(input("Enter exponent number:")); result=1; for i in range(1,exponentNumber+1): result=result*baseNumber print(result) |