There is no do-while loop in Python.

This is a similar construct, taken from the link above.

 while True:
     do_something()
     if condition():
        break
Answer from theycallmemorty on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-do-while
Python Do While Loops - GeeksforGeeks
July 23, 2025 - Do while loop is a type of control looping statement that can run any statement until the condition statement becomes false specified in the loop. In do while loop the statement runs at least once no matter whether the condition is false or true.
🌐
W3Schools
w3schools.com › python › python_while_loops.asp
Python While Loops
Python Examples Python Compiler ... Certificate Python Training ... With the while loop we can execute a set of statements as long as a condition is true....
Discussions

How to make a loop repeat until a condition is met. I want going left to be the condition that needs to be met.
Hello, I'm a Reddit bot who's here to help people nicely format their coding questions. This makes it as easy as possible for people to read your post and help you. I think I have detected some formatting issues with your submission: Python code found in submission text that's not formatted as code. If I am correct, please edit the text in your post and try to follow these instructions to fix up your post's formatting. Am I misbehaving? Have a comment or suggestion? Reply to this comment or raise an issue here . More on reddit.com
🌐 r/learnpython
12
0
November 22, 2022
I need help in understanding while loop
It's nothing more than a loop that keeps running as long as the condition you give it evaluates to True. If you do while True, you get an infinite loop. If you do white x > 3, you get a loop that keeps repeating as long as the value of x is greater than 3. If you do while someFunction(), you get a loop that keeps repeating as long as someFunction() returns True. If you do while False, it never runs anything at all. This code; x = 3 while x != 0: print(x) x -= 1 print("Done!") Basically performs these steps; Set x to 3 x is not 0, so run the loop once Print x, then decrement it by 1. x is now 2 x is still not 0, so run the loop again Print x, then decrement it by 1. x is now 1 x is still not 0, so the loop runs a 3rd time Print x, then decrement it by 1. x is now 0. x is now 0, so the while loop's condition now evaluates to False and the loop will not run again. Print "Done!" More on reddit.com
🌐 r/learnpython
12
1
August 21, 2023
How do you loop until correct input is given?
First find what loop you need. If the number of iterations is known beforehand then for. If not known then while. Then find how to draw a random number. Test in the python interpreter. Then find how to use the input function. Test in tje python interpreter. Brick by brick you will build you way ;) More on reddit.com
🌐 r/learnpython
33
29
February 25, 2022
Why not add do-while loops to Python?
I think the assignment expressions of PEP 572 are being implemented partly because of this. It’s even one of the examples: https://www.python.org/dev/peps/pep-0572/#id22 More on reddit.com
🌐 r/Python
22
3
August 30, 2019
🌐
freeCodeCamp
freecodecamp.org › news › python-do-while-loop-example
Python Do While – Loop Example
August 31, 2021 - Before any code is run, Python checks the condition (number < 10). It evaluates to True so the print statement gets executed and Number is 0! is printed to the console. number is then incremented by 1. The condition is re-evaluated and it is ...
🌐
Medium
medium.com › @BetterEverything › until-loops-and-do-while-loops-in-python-this-is-how-bfe43b22e6b4
Until Loops and Do While Loops in Python? This is how! | by Better Everything | Medium
August 13, 2024 - To make an Until loop we need to loop until a certain condition evaluates to True. To do that, we can choose between a for loop or a while loop to start repeating lines of code. In the loop we put an if-statement to check a condition.
🌐
DataCamp
datacamp.com › tutorial › do-while-loop-python
Emulating a Do-While Loop in Python: A Comprehensive Guide for Beginners | DataCamp
January 31, 2024 - Here's an example: while True: ... mimicking the behavior of a "do-while" loop. Consider a scenario where you want to repeatedly prompt a user for input until they provide a valid response....
🌐
W3Schools
w3schools.com › python › ref_keyword_while.asp
Python while Keyword
Python Examples Python Compiler ... Training ... The while keyword is used to create a while loop. A while loop will continue until the statement is false....
🌐
Texas Instruments
education.ti.com › en › resources › computer-science-foundations › do-while-loops
Python coding: Do While Loops | Texas Instruments
So, what happens after the else command executes and the value of n gets saved in t? Well, we’re at the end of our loop, so the loop will circle back to its beginning. (Since the conditional for this While loop is True, it will keep running until it encounters a break command.)
Find elsewhere
🌐
Programiz
programiz.com › python-programming › while-loop
Python while Loop (With Examples)
Created with over a decade of experience. ... Created with over a decade of experience and thousands of feedback. ... Try Programiz PRO! ... Become a certified Python programmer. Try Programiz PRO! ... In Python, we use a while loop to repeat a block of code until a certain condition is met.
🌐
W3Schools
w3schools.com › python
Python Tutorial
Note: This is an optional feature. You can study at W3Schools without creating an account. You will also find complete function and method references: Reference Overview Built-in Functions String Methods List / Array Methods Dictionary Methods Tuple Methods Set Methods File Methods Python Keywords Python Exceptions Python Glossary Random Module Requests Module Statistics Module Math Module CMath Module · Download Python from the official Python web site: https://python.org
🌐
YoungWonks
youngwonks.com › blog › do-while-loop-python
What is a do while loop in Python? How do I create a while loop in Python? What is the difference between a for loop and a while loop in Python?
February 18, 2024 - Otherwise, the loop continues. For example, if we want to ask the user to enter a number between 1 and 10 and repeat the question until the user enters a valid number, we can use a do-while loop like this:
🌐
Quora
quora.com › Does-Python-have-an-until-loop
Does Python have an until loop? - Quora
Answer (1 of 7): P̲y̲t̲h̲o̲n̲ ̲d̲o̲e̲s̲n̲’̲t̲ ̲h̲a̲v̲e̲ ̲a̲ ̲d̲e̲d̲i̲c̲a̲t̲e̲d̲ ̲`̲u̲nt̲i̲l̲`̲ ̲l̲o̲o̲p̲ ̲l̲i̲k̲e̲ ̲R̲u̲b̲y̲ ̲o̲r̲ ̲s̲o̲m̲e̲ ̲o̲t̲h̲e̲r̲ ̲l̲a̲n̲g̲u̲a̲g̲e̲s̲ ̲,̲ ̲b̲u̲t̲ ̲y̲o̲u̲ ̲c̲a̲n̲ ̲e̲a̲s̲i̲l̲y̲ ̲r̲e̲p̲l̲i̲c̲a̲t̲e̲ ̲t̲h̲e̲ ̲b̲e̲h̲av̲io̲r̲ ̲u̲si̲n̲g̲ ̲a̲ ̲`̲w̲h̲i̲l̲e̲`̲ ̲l̲o̲o̲...
🌐
Real Python
realpython.com › python-do-while
How Can You Emulate Do-While Loops in Python? – Real Python
August 2, 2022 - In this tutorial, you'll learn how to emulate do-while loops in Python. The most common technique to do this is to create an infinite while loop with a conditional statement that controls the loop and jumps out of it using a break statement.
🌐
Server Academy
serveracademy.com › blog › python-while-loop-tutorial
Python While Loop Tutorial - Server Academy
This example uses the time.sleep() function to create a 1-second delay between each countdown number. The while loop is a versatile and powerful control structure in Python that can help you manage iterative tasks based on conditions. Here’s a recap of key points: Basic Usage: Use a while loop to repeat a block of code as long as a condition is true. break: Use break to exit a while loop before the condition becomes false. Simulating do while Loops: Python doesn’t have a native do while loop, but you can simulate it using a while True loop with break.
🌐
iO Flood
ioflood.com › blog › python-do-while
Python Do-While Loop: Ultimate How-To Guide
June 7, 2024 - It allows us to perform a task repeatedly until a certain condition is met, just like a detective tirelessly gathering clues until the case is solved. As you become more comfortable with Python’s do-while loops, you can start exploring more ...
🌐
W3Schools
w3schools.com › c › c_do_while_loop.php
C Do While Loop
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
🌐
Python documentation
docs.python.org › 3 › tutorial › controlflow.html
4. More Control Flow Tools — Python 3.14.3 documentation
In many ways the object returned by range() behaves as if it is a list, but in fact it isn’t. It is an object which returns the successive items of the desired sequence when you iterate over it, but it doesn’t really make the list, thus saving space. We say such an object is iterable, that is, suitable as a target for functions and constructs that expect something from which they can obtain successive items until the supply is exhausted. We have seen that the for statement is such a construct, while an example of a function that takes an iterable is sum():
🌐
Real Python
realpython.com › python-while-loop
Python while Loops: Repeating Tasks Conditionally – Real Python
March 3, 2025 - For example, you might want to write code for a service that starts up and runs forever, accepting service requests. Forever, in this context, means until you shut it down.