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....
Discussions

python - Is the continue statement necessary in a while loop? - Stack Overflow
I'm confused about the use of the continue statement in a while loop. In this highly upvoted answer, continue is used inside a while loop to indicate that the execution should continue (obviously)... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Can someone explain what this `while True` function is actually checking?
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: ") More on reddit.com
๐ŸŒ r/learnpython
14
17
December 13, 2023
syntax - What does "while True" mean in Python? - Stack Overflow
Unlike most languages, for example, Python can have an else clause on a loop. There is an example in the last link. ... While most of these answers are correct to varying degrees, none of them are as succinct as I would like. Put simply, using while True: is just a way of running a loop that will continue ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
sorry to ask such a silly question but what does 'while True:' actually mean?
while will always evaluate whatever comes behind it. For instance i =0 while i < 10: print(i) i = i+ 1 Here i <10 is evaluated to either be true or false. This will happen each iteration. i = 0 , True i= 1, True i= 2, True Etc, untill: i=10, False => break loop The code will continue untill it evaluates to false. while True kind of hacks it: True will always evaluate to True. While looks at it and thinks: hey this is true! So it always continues. While true isn't commonly used, but when it is it's commonly used with a break statement. (Or interrupted by ctrl + c). While False will never do anything in the loop as you stated. It checks to see if False is True. But it's never true, so it doesnt execute the code in the while loop. (Sorry fod bas formatting, mobile) More on reddit.com
๐ŸŒ r/learnpython
71
76
November 14, 2023
People also ask

How Does a While Loop differ from a For Loop in Python?
A While Loop runs based on a condition and is ideal when the number of iterations is uncertain. In contrast, a for loop iterates over a sequence like a list or range, and is best used when the number of iterations is predefined or fixed.
๐ŸŒ
theknowledgeacademy.com
theknowledgeacademy.com โ€บ blog โ€บ python-while-loop
Python While Loop: Everything You Should Know
Can I Use Functions Inside While Loops?
Yes, you can use functions inside While Loops. Functions help organise code, perform repeated tasks, and return values that can influence loop conditions. This makes your code cleaner, more efficient, and easier to debug, especially when complex operations are needed within each iteration of the loop
๐ŸŒ
theknowledgeacademy.com
theknowledgeacademy.com โ€บ blog โ€บ python-while-loop
Python While Loop: Everything You Should Know
What is a Strange Loop?
A strange loop refers to a situation where a function or operation appears to reference itself in a way that creates a loop recursively, but it doesn't follow the traditional recursive paradigm. This can lead to complex structures and self-referencing patterns.
๐ŸŒ
theknowledgeacademy.com
theknowledgeacademy.com โ€บ blog โ€บ python-while-loop
Python While Loop: Everything You Should Know
๐ŸŒ
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 ย  3 days ago
๐ŸŒ
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.
Find elsewhere
๐ŸŒ
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.
๐ŸŒ
The Knowledge Academy
theknowledgeacademy.com โ€บ blog โ€บ python-while-loop
Python While Loop: Everything You Should Know
3 weeks ago - 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....
๐ŸŒ
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โ€™...
๐ŸŒ
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: ...
๐ŸŒ
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: ")
๐ŸŒ
TOOLSQA
toolsqa.com โ€บ python โ€บ python-while-loop
Python While Loop | While True and While Else in Python || ToolsQA
August 6, 2021 - 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 ...
๐ŸŒ
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โ€ฆ
๐ŸŒ
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
๐ŸŒ
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!
๐ŸŒ
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 ...