Python while loop

In this article, we will see Python while loop definition and examples.

While loop is used to execute number of statements or body till the condition passed in while is TRUE. Once the condition is FALSE, the control will come out of the loop.

Python while loop flow diagram:

Python while loop

Python while loop Syntax:

while : body

Python while loop examples:

1. Print numbers from 1 to 10 without using any function.

i=1 while(i<=10): print(i) i=i+1

Output:

Python while loop