The continue statement ignores the rest of the loop and returns back to the top for the next iteration.

In your example count is 0 at the beginning. Since it is not equal to 5, the if statement is not executed and count is printed in incremented by one. When count finally reaches 5 after 5 iterations or the loop, the if statement is executed. Since the only instruction is continue, the print and increment are never executed: the rest of the loop body is ignored. After this point count always has a value of 5 and this state continues indefinitely.

It does not break the loop, the loop is still running forever, doing nothing.

count = 0

while count < 15:
  if count == 5:
    continue

  # The following is ignored after count == 4
  print(count)
  count += 1
Answer from Louis Lac on Stack Overflow
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ gloss_python_while_continue.asp
Python While Continue
Python Dictionaries Access Items Change Items Add Items Remove Items Loop Dictionaries Copy Dictionaries Nested Dictionaries Dictionary Methods Dictionary Exercises Code Challenge Python If...Else ยท Python If Python Elif Python Else Shorthand If Logical Operators Nested If Pass Statement Code Challenge Python Match ยท Match Code Challenge Python While Loops ยท
Discussions

Can't understand "Continue" function in Python statement(for loop, while loop) !!
It jumps directly to the next iteration of a loop. In the code below the continue function skips the print statement below it so that "odd" is only printed on odd numbers. for i in range(10): if i%2==0: print("even") continue print("odd") More on reddit.com
๐ŸŒ r/learnpython
20
44
November 9, 2019
How continue works in while loop
name = 'Jesaa29 Roy' size = len(name) i = 0 while i More on discuss.python.org
๐ŸŒ discuss.python.org
0
0
October 18, 2022
What is the most pythonic way to limit while loop iterations?
What about just a for range? for _ in range(0, 100): โ€ฆ More on reddit.com
๐ŸŒ r/Python
49
41
March 13, 2022
How to continue code while websocket is open?
Welcome to multithreading. Lookup python threading library More on reddit.com
๐ŸŒ r/algotrading
26
30
August 9, 2020
๐ŸŒ
Tutorialspoint
tutorialspoint.com โ€บ python โ€บ python_loop_control.htm
Python Break, Continue and Pass Statements
The continue statement can be used in both while and for loops. for letter in 'Python': # First Example if letter == 'h': continue print ('Current Letter :', letter) var = 10 # Second Example while var > 0: var = var -1 if var == 5: continue ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-continue-statement
Python Continue Statement - GeeksforGeeks
The continue statement in Python is a loop control statement that skips the rest of the code inside the loop for the current iteration and moves to the next iteration immediately.
Published ย  3 days ago
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ ref_keyword_continue.asp
Python continue Keyword
Python Examples Python Compiler ... Certificate Python Training ... The continue keyword is used to end the current iteration in a for loop (or a while loop), and continues to the next iteration....
Find elsewhere
๐ŸŒ
Real Python
realpython.com โ€บ python-while-loop
Python while Loops: Repeating Tasks Conditionally โ€“ Real Python
March 3, 2025 - The control then returns to the loop header, where the condition is re-evaluated. The loop continues until number reaches 0, at which point it terminates as before. ... Python allows an optional else clause at the end of while loops.
๐ŸŒ
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โ€ฆ
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ break-continue
Python break and continue (With Examples)
We can also terminate the while loop using the break statement. For example, i = 0 while i < 5: if i == 3: break print(i) i += 1 ... The continue statement skips the current iteration of the loop and the control flow of the program goes to the next iteration.
๐ŸŒ
Python documentation
docs.python.org โ€บ 3 โ€บ tutorial โ€บ controlflow.html
4. More Control Flow Tools โ€” Python 3.14.3 documentation
The break statement breaks out ... 2 * 2 6 equals 2 * 3 8 equals 2 * 4 9 equals 3 * 3 ยท The continue statement continues with the next iteration of the loop:...
๐ŸŒ
DigitalOcean
digitalocean.com โ€บ community โ€บ tutorials โ€บ how-to-use-break-continue-and-pass-statements-when-working-with-loops-in-python-3
How to Break Out of Multiple Loops in Python | DigitalOcean
August 7, 2025 - The break statement in Python allows you to exit a loop immediately when a specific condition is met, which is especially useful for terminating early during search or validation operations. The continue statement skips the rest of the current iteration and moves to the next cycle of the loop, ...
๐ŸŒ
Tutorialspoint
tutorialspoint.com โ€บ python โ€บ python_continue_statement.htm
Python - Continue Statement
Python continue statement is used to skip the execution of the program block and returns the control to the beginning of the current loop to start the next iteration. When encountered, the loop starts next iteration without executing the remaining
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ break-continue-and-pass-in-python
Python - Loop Control Statements
January 9, 2025 - # Using For Loop for i in range(5): ... statement is a loop control statement that forces to execute the next iteration of the loop while skipping the rest of the code inside the loop for the current iteration only, i.e...
๐ŸŒ
H2K Infosys
h2kinfosys.com โ€บ blog โ€บ python break, continue and pass statements in loops
Python Break, Continue and Pass Statements in Loops
January 5, 2026 - In contrast, a while loop repeatedly executes a block of code as long as a specified condition remains true, making it useful for tasks that depend on dynamic conditions rather than a fixed sequence. But when working with loops, you can change how the iteration is done using the python break, continue and pass statement.
๐ŸŒ
YouTube
youtube.com โ€บ real python
How to Use "break" and "continue" in Python "while" Loops - YouTube
Youโ€™ll walk through practical examples of how to use "break" and "continue" in Python when you're dealing with "while" loops. You'll debug the example code, ...
Published ย  July 2, 2019
Views ย  11K
๐ŸŒ
Coursera
coursera.org โ€บ tutorials โ€บ python-while-loop
How to Write and Use Python While Loops | Coursera
The if statement checks whether the current value of i is even. If it is, the continue statement is executed, causing the loop to skip the current iteration and move on to the next one without executing the rest of the loop body.
๐ŸŒ
LearnDataSci
learndatasci.com โ€บ solutions โ€บ python-continue
Python Continue - Controlling for and while Loops โ€“ LearnDataSci
These statements follow a stringent ... allowing you to govern your code in different manners. As mentioned previously, continue is used to skip to the end of the current iteration of a loop......
๐ŸŒ
Built In
builtin.com โ€บ software-engineering-perspectives โ€บ pass-vs-continue-python
Pass vs. Continue in Python Explained | Built In
In Python, break stops a loop once its condition is met, while continue skips over the current iteration of a loop and continues to the next iteration based on its condition.
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ python-break-and-python-continue-how-to-skip-to-the-next-function
Python Break and Python Continue โ€“ How to Skip to the Next Function
March 14, 2022 - As you can see, the number 50 is not printed to the console because of the continue statement inside the if statement. The break and continue statements in Python are used to skip parts of the current loop or break out of the loop completely.
๐ŸŒ
Learn Python
learnpython.dev โ€บ 02-introduction-to-python โ€บ 110-control-statements-looping โ€บ 40-break-continue
break, continue, and return :: Learn Python by Nina Zakharenko
break in the inner loop only breaks out of the inner loop! The outer loop continues to run. You can also use break and continue in while loops.