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 - In this tutorial, you'll learn about indefinite iteration using the Python while loop. You'll be able to construct basic and complex while loops, interrupt loop execution with break and continue, use the else clause with a while loop, and deal with infinite loops.
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-use-while-true-in-python
How to use while True in Python - GeeksforGeeks
July 23, 2025 - This makes while True loops extremely ... the loop tells you to stop. Example 1: In this example, we use while True to create an infinite loop using the pass statement....
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-continue-statement
Python Continue Statement - GeeksforGeeks
Example: Python · for i in range(1, 11): if i == 6: continue print(i, end=" ") Output · 1 2 3 4 5 7 8 9 10 · Explanation: When i == 6, the continue statement executes, skipping the print operation for 6. while True: ...
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 this example, the loop will run indefinitely, calling the "get_new_content()" function each time to check for new content. If new content is available, it is appended to the page using the "append_to_page()" function.
🌐
W3Schools
w3schools.com › python › python_while_loops.asp
Python While Loops
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Certificate Python Training ... With the while loop we can execute 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
HTML Reference CSS Reference JavaScript Reference SQL Reference Python Reference W3.CSS Reference Bootstrap Reference PHP Reference HTML Colors Java Reference AngularJS Reference jQuery Reference · HTML Examples CSS Examples JavaScript Examples How To Examples SQL Examples Python Examples W3.CSS Examples Bootstrap Examples PHP Examples Java Examples XML Examples jQuery Examples
🌐
Stanford CS
cs.stanford.edu › people › nick › py › python-while.html
While Loop
Given that we have if/break to get out of the loop, it's possible to get rid of the test at the top of the loop entirely, relying on if/break to end the loop. We do this by writing the loop as while True:... Here is an example that uses while/True to go through the numbers 0..9.
Find elsewhere
🌐
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 "True" (no pun intended!). ... Use this condition carefully as if your break statement is never touched. Your loop will continuously ...
🌐
Python documentation
docs.python.org › 3 › tutorial › controlflow.html
4. More Control Flow Tools — Python 3.14.3 documentation
The pass statement does nothing. It can be used when a statement is required syntactically but the program requires no action. For example: >>> while True: ...
🌐
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 - Let’s take a hypothetical example. You may ask a user to submit a secret keyword so they can access a specific part of your site. Say that for them to be able to view some content, they first have to enter the keyword ‘Python’...
🌐
The Knowledge Academy
theknowledgeacademy.com › blog › python-while-loop
Python While Loop: Everything You Should Know
When the continue statement comes ... in Programming. ... In this example, when count equals 3, the continue statement skips the print statement and moves to the next iteration of the loop....
🌐
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: ")
🌐
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!

🌐
Python.org
discuss.python.org › python help
How continue works in while loop - Python Help - Discussions on Python.org
October 18, 2022 - name = 'Jesaa29 Roy' size = len(name) i = 0 while i < size: if name[i].isspace(): continue print(name[i], end=' ') i = i + 1 #it’s supposed to print name without space “Jessa29Roy”, but the output i…
🌐
TutorialsPoint
tutorialspoint.com › what-does-while-true-do-in-python
What Does while true do in Python?
Now let?s understand the next example with a counter. count = 0 while True: count += 1 if count > 15: break print(count) ... This is because the loop starts with the variable count equal to 0, and then increments it by 1 on each iteration until ...
🌐
Programiz
programiz.com › python-programming › while-loop
Python while Loop (With Examples)
For example, while True: user_input = input("Enter password: ") # terminate the loop when user enters exit if user_input == 'exit': print(f'Status: Entry Rejected') break print(f'Status: Entry Allowed') ... Before we wrap up, let’s put your knowledge of Python while loop to the test!
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-while-loop
Python While Loop - GeeksforGeeks
If it evaluates to True, the code ... during each iteration of the loop. ... The while loop will continue running the code block as long as the condition evaluates to True....
Published   December 23, 2025