Javatpoint Logo
Javatpoint Logo

Python Do While Loop

Python doesn't have do-while loop. But we can create a program like this.

The do while loop is used to check condition after executing the statement. It is like while loop but it is executed at least once.

General Do While Loop Syntax

do {
     //statement
} while (condition);

Python Do While Loop Example

i = 1

while True:
    print(i)
    i = i + 1
    if(i > 5):
        break

Output:

1
2
3
4
5




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA