How to emulate a do-while loop in Python

A do-while loop checks its termination condition at the end of every iteration, instead of at the beginning. As a result, do-while loops always complete at least one iteration before being terminated.

Solution for How to emulate a do-while loop in Python : You can use break to emulate a do-while loop Use a while loop with condition True. At the end of the code block, include an if statement with the termination condition of the do-while loop. In the body of the if statement, use break.


how-to-emulate-a-do-while-loop-in-python