How to used Do while loop in python

Hassan typist
2 min readSep 10, 2021

--

https://www.programmerclick.site/how-to-used-do-while-loop-in-python/

How to used Do while loop in python

In the previous Tutorials, we dissected For loop. Now in these tutorials, we will discuss do while loop in Python? How to Do while loop work in Python.

The Do-While loop is used repeatedly to iterate the part of the program which you want and the program will stop when it reaches the specified condition. If you don’t know the iteration number or the number is not fixed of iteration then we can use a do-while loop.
Do_while loop is also called exit while loop because the do-while loop is checked the condition at the end of the program as shown in the figure:
And the Do-while loop can execute one time before checking the condition because the condition is checking at the end of the program.

Syntax of the do-while loop:

do
{
Here we can write some program line
} while (Here we can write the condition for has a program );

How to do while loop work:

First executed the code which is present inside of the loop
when the code executes then it passes through the condition
if the condition is true then it is transferred to the “do” and
its jumps to the next code which is present. The method is
present in the figure.

[caption id=”attachment_351" align=”alignnone” width=”300"]

https://www.programmerclick.site/how-to-used-do-while-loop-in-python/

do-while loop in python[/caption]

part of the do-while loop in python

Condition: It shows the test parts of the loop. if the given condition is true then it executes and the program and if the condition is false then it can stop the at that point further can not move. For example, a>10 is the type of condition but it is not necessary to use this condition you can use any type of condition which you want.

Do while loop Example:

z=1

while true;

print(z)

z=z+1

if(z>3):

break

--

--

No responses yet