Here's a really simple example where continue actually does something measureable:

animals = ['dog', 'cat', 'pig', 'horse', 'cow']
while animals:
    a = animals.pop()
    if a == 'dog':
        continue
    elif a == 'horse':
        break
    print(a)

You'll notice that if you run this, you won't see dog printed. That's because when python sees continue, it skips the rest of the while suite and starts over from the top.

You won't see 'horse' or 'cow' either because when 'horse' is seen, we encounter the break which exits the while suite entirely.

With all that said, I'll just say that over 90%1 of loops won't need a continue statement.

1This is complete guess, I don't have any real data to support this claim :)

Answer from mgilson on Stack Overflow
๐ŸŒ
Real Python
realpython.com โ€บ python-while-loop
Python while Loops: Repeating Tasks Conditionally โ€“ Real Python
March 3, 2025 - continue: Ends only the current iteration. The execution jumps back to the loop header, and the loop condition is evaluated to determine whether the loop will execute again. Pythonโ€™s while loops also have additional syntax.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ how-to-use-while-true-in-python
How to use while True in Python - GeeksforGeeks
July 23, 2025 - The while loop runs as long as a given condition is true. Using while True creates an infinite loop that runs endlessly until stopped by a break statement or an external interruption. Its main uses include: Continuously prompt user input until ...
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ ending while true loop
r/learnpython on Reddit: Ending While True Loop
August 17, 2023 -

I'm doing a CS50p project on making a grocery list. The only issue I'm having is once the list prints, I need the program to end. No matter where I break, it either doesn't stop the program or does stop it but bugs something else.
This is what I have:

def main():
list = []
while True:
    try:
        item = input()
        list.insert(0, item)
        continue
    except EOFError:
        list.sort()
        while list != None:
            for word in list:
                x = list.count(word)
                if x != 0:
                    print(str(x) + " " + str.upper(word), sep=" ")
                    list = [i for i in list if i!=word]
                else:
                    break
        break

main()

๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-continue-statement
Python Continue Statement - GeeksforGeeks
Python ยท for i in range(1, 11): if i == 6: continue print(i, end=" ") Explanation: When i == 6, the continue statement executes, skipping the print operation for 6. while True: ... if x == 10: continue print(x) Parameters : The continue statement does not take any parameters.
Published ย  July 12, 2025
๐ŸŒ
Board Infinity
boardinfinity.com โ€บ blog โ€บ use-while-true-in-python
Use While True in Python | Board Infinity
August 13, 2025 - In conclusion, the "while True" loop is a useful tool in Python programming that allows a block of code to be repeated indefinitely. It is often used with a break statement to exit the loop under certain conditions.
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ while-loops-in-python-while-true-loop-statement-example
While Loops in Python โ€“ While True Loop Statement Example
July 19, 2022 - If the condition evaluates to True, then the loop will run the code within the loop's body and continue to run the code while the condition remains True. It will keep executing the desired set of code statements until that condition is no longer ...
Find elsewhere
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_while_loops.asp
Python While Loops
Python Examples Python Compiler ... a set of statements as long as a condition is true. ... Note: remember to increment i, or else the loop will continue forever....
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ gloss_python_while_continue.asp
Python While Continue
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.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ sorry to ask such a silly question but what does 'while true:' actually mean?
r/learnpython on Reddit: sorry to ask such a silly question but what does 'while True:' actually mean?
November 14, 2023 -

what does the True refer to?

eg if i write:

while True: 
    print("hi")

i know that "hi" will be repeated infinitely, but what is it thats True thats making "hi" get printed?

also, whatever it is thats True, im assuming its always true, so is that why if i typed 'while False', none of the code below would ever run?

sorry if this is a stupid question

edit: also, besides adding an if statement, is there anything else that would break this infinite while loop?

and how would i break the loop, lets say after "hi" has been printed 10 times, using an if statement or whatever else there is that can break it. thanks!

๐ŸŒ
TOOLSQA
toolsqa.com โ€บ python โ€บ python-while-loop
Python While Loop | While True and While Else in Python || ToolsQA
The while true in python is simple to implement. Instead of declaring any variable, applying conditions, and then incrementing them, write true inside the conditional brackets. ... The following code will run infinitely because "True" is always ...
๐ŸŒ
Python.org
discuss.python.org โ€บ python help
What actually "while true" statement mean can someone pull me out this? - Python Help - Discussions on Python.org
April 30, 2022 - What actually "while true" statement mean can someone pull me out this ยท In practical terms, it will loop a code block, while a particular condition is True. Said condition may never be True, in which case you get an infinite loop, or you can set and test a variable so that you have a fixed ...
๐ŸŒ
Note.nkmk.me
note.nkmk.me โ€บ home โ€บ python
Python while Loop (Infinite Loop, break, continue) | note.nkmk.me
August 18, 2023 - Infinite iterators in Python (itertools.count, cycle, repeat) ... You can specify multiple conditions for the condition part with and or or. ... Use break to break a while loop. i = 0 while i < 3: print(i) if i == 1: print('!!BREAK!!') break i += 1 # 0 # 1 # !!BREAK!! ... You can skip the current iteration and move to the next one using the continue statement.
๐ŸŒ
The Knowledge Academy
theknowledgeacademy.com โ€บ blog โ€บ python-while-loop
Python While Loop: Everything You Should Know
A Python While Loop with a continue statement keeps executing a code block as long as the specified condition remains true, skipping over the rest of the loop's body when the continue statement is encountered.
๐ŸŒ
Stanford CS
cs.stanford.edu โ€บ people โ€บ nick โ€บ py โ€บ python-while.html
While Loop
While Operation: Check the boolean test expression, if it is True, run all the "body" lines inside the loop from top to bottom. Then loop back to the top, check the test again, and so on. When the test is False, exit the loop, running continues on the first line after the body lines.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ can someone explain what this `while true` function is actually checking?
r/learnpython on Reddit: Can someone explain what this `while True` function is actually checking?
December 13, 2023 -

https://pastebin.com/NWkKQc1P

It's from Automate the Boring Stuff. I tried running it through the python tutor and it didn't clarify. Is the basic point that there actually isn't anything it's checking to be True, so it's an infinite loop until you trigger the `break`?

PS I figure this is something simple from much earlier that I didn't internalize. I plan to go through all the basic curriculum again to make sure there aren't any gaps in super basic knowledge.

Top answer
1 of 8
23
A while loop runs while a condition is true. True is always true, so it will run until something causes it to break (e.g. a break statement, program crash, etc.) For comparison, the first loop in the code you posted could be rewritten without an infinite loop as: age = input("Enter your age: ") while not age.isdecimal(): age = input("Please enter a number for your age: ")
2 of 8
9
Correct; this is just a way to start an infinite loop that you intend to break with some condition/break statement later on. Mostly used for starting/running an application that you don't want to close down without user intent (clicking an exit/quit button in a UI or entering "quit", "exit", etc from the command line. It *isn't* a great construct to use when you want something that has solidly defined criteria to repeat until those criteria are met. As mopslik pointed out, you would be better served in those examples to actually use the defined criteria in those as your loop conditions since you're not at risk of just sticking the user in an infinite loop if you forget to write your break statement somewhere. You, also, don't have to write so many lines to accomplish the same goal. ``` password = "" while not password.isalnum(): password = input('Select a new password (alphanumeric only') print("Password is good") ``` You do not have to print a line and then call input(), either. Just put the message you want displayed into the parens for the function call: input("Enter your age: ")
๐ŸŒ
Medium
medium.com โ€บ @huasa0115 โ€บ python-how-to-use-the-continue-keyword-in-for-while-loops-19aa860a50d5
[Python] How to use the continue keyword in for/while loops? | by Yi-Ning Huang | Medium
May 26, 2025 - i = 0 while i < 10: i += 1 if i % 2 == 0: continue # Skip even numbers print(i) # even numbers not printed ... Data & Analytics Engineer in US healthcare. Writing about SQL, Python, PySpark, and the healthcare meaning behind the data.