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
🌐
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
Need help understanding this while loop
I’m new to while loops, and I don’t quite get what’s going on in this code from my book: current_number = 1 while current_number More on discuss.python.org
🌐 discuss.python.org
0
0
February 13, 2024
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 again True, so the whole procedure repeats until number is equal to 9. This time Number is 9! is printed and number is incremented, but now number is equal to 10 so the condition is no longer met and therefore the loop is terminated.
🌐
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̲...
🌐
Python
wiki.python.org › moin › ForLoop
ForLoop
The for loop runs for a fixed amount of times, while the while loop runs until the loop condition changes. In this example, the condition is the boolean True which will never change, so it will run forever. If you've done any programming before, you have undoubtedly come across a for loop or ...
🌐
Real Python
realpython.com › python-while-loop
Python while Loops: Repeating Tasks Conditionally – Real Python
March 3, 2025 - while True in Python creates an infinite loop that continues until a break statement or external interruption occurs. Python lacks a built-in do-while loop, but you can emulate it using a while True loop with a break statement for conditional ...
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-do-while
Python Do While Loops - GeeksforGeeks
July 23, 2025 - In Python, we can simulate the ... when the desired condition is met. Do while loop is a type of control looping statement that can run any statement until the condition statement ......
🌐
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 - Here's how you can write a do-while loop in Python: The while True statement creates an infinite loop, which will run indefinitely unless we stop it. The if not conditional statements checks the opposite of the loop condition we want to use ...
🌐
Python documentation
docs.python.org › 3 › tutorial › controlflow.html
4. More Control Flow Tools — Python 3.14.3 documentation
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(): ... Later we will see more functions that return iterables and take iterables as arguments. In chapter Data Structures, we will discuss list() in more detail. The break statement breaks out of the innermost enclosing for or while loop:
🌐
Simplilearn
simplilearn.com › home › resources › software development › your ultimate python tutorial for beginners › introduction to python while loop
Introduction to Python While Loop
May 27, 2024 - Python is an object-oriented programming language consisting of three types of loops. Learn about the Python While loop, break and continue statements, & more.
Address   5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States
🌐
GeeksforGeeks
geeksforgeeks.org › python › loops-in-python
Loops in Python - GeeksforGeeks
In Python, a while loop is used to execute a block of statements repeatedly until a given condition is satisfied. When the condition becomes false, the line immediately after the loop in the program is executed.
Published   1 month ago
🌐
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.
🌐
Python.org
discuss.python.org › python help
Need help understanding this while loop - Python Help - Discussions on Python.org
February 13, 2024 - I’m new to while loops, and I don’t quite get what’s going on in this code from my book: current_number = 1 while current_number <= 5: print(current_number) current_number += 1 After just watching a video on Yo…
🌐
Reddit
reddit.com › r/learnpython › how do you loop until correct input is given?
r/learnpython on Reddit: How do you loop until correct input is given?
February 25, 2022 -

I'm doing an assignment that requires I make a code that creates random numbers in a loop until I give a specific input. I just don't know how to get the loop to run while an input is requested. PLZ HELP!

EDIT:

To clarify the assignment:

Write a program that enters a number of positive integers.

The program ends when the user gives in a negative number.

a) Before the program ends, the largest number is printed.

b) Before the program ends, the smallest number is printed.

c) Before the program ends, the sum of the even numbers and the sum of the odd numbers are printed.

(I can do the a,b,c part no problem. It's the Program that creates the numbers i have problems with)

I asked my teacher what he meant by "a number of positive integers". He stated that the program should create numbers until the negative number is given.

EDIT 2:

I have concluded that I'm an idiot. It is the user who inputs the numbers. Thank you all for the help and not giving up with my dense skull :) (great community👍)

🌐
Scaler
scaler.com › home › topics › python do while loop
Python Do While Loop - Scaler Topics
December 1, 2023 - Python While Loop is used to execute a block of statements repeatedly until a given condition is satisfied, and when the condition becomes false, the line immediately after the Loop in the program is executed.
🌐
Texas Instruments
education.ti.com › en › resources › computer-science-foundations › do-while-loops
Python coding: Do While Loops | Texas Instruments
Note that this loop structure is slightly different than Do While loop structures that appear in other programming languages. Python doesn’t have a built-in Do While loop structure, but the behavior of a Do While loop can be modeled with programs that use While, If and break commands as we’re exploring here.
🌐
EDUCBA
educba.com › home › software development › software development tutorials › python tutorial › do while loop in python
Do While Loop in Python | Emulate Do While Loop in Python(Example)
March 17, 2023 - So in Python, it can be done with a while statement using the break/continue/if statements if the while condition is not satisfied, which is similar to do while loop as in other languages.
Address   Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
Server Academy
serveracademy.com › blog › python-while-loop-tutorial
Python While Loop Tutorial - Server Academy
November 12, 2024 - While infinite loops can be useful, they should be used with caution to avoid unintentional infinite runs. while True: print("This will run forever unless stopped manually.") This code will continue printing indefinitely until you manually interrupt it, such as by pressing Ctrl + C in most terminals. An interesting feature in Python is that you can pair while with else.