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 OverflowGeeksforGeeks
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....
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
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
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
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
Top answer 1 of 4
337
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
2 of 4
54
I prefer to use a looping variable, as it tends to read a bit nicer than just "while 1:", and no ugly-looking break statement:
finished = False
while not finished:
... do something...
finished = evaluate_end_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.)
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
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̲...
Reddit
reddit.com › r/learnpython › how to make a loop repeat until a condition is met. i want going left to be the condition that needs to be met.
r/learnpython on Reddit: How to make a loop repeat until a condition is met. I want going left to be the condition that needs to be met.
November 22, 2022 -
print("You're in the lost forest\n" + "*" 25) print("" 25) print(" :-( ") print("" 25) print("" *25) print("Right or Left")
which_way = (str.capitalize(input ())) while which_way == "Right": print("HaHaHa!!! You are still in the forest!!!") break
Top answer 1 of 4
3
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 .
2 of 4
2
while which_way != "Left":
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.
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():