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 Glossary · With the continue statement we can stop the current iteration, and continue with the next: Continue to the next iteration if i is 3: i = 0 while i < 6: i += 1 if i == 3: continue print(i) Try it Yourself » · Python While ...
🌐
Programiz
programiz.com › python-programming › break-continue
Python break and continue (With Examples)
# Program to print odd numbers from 1 to 10 num = 0 while num < 10: num += 1 if (num % 2) == 0: continue print(num) ... In the above example, we have used the while loop to print the odd numbers between 1 and 10. Here, ... Before we wrap up, let’s put your knowledge of Python break and continue ...
🌐
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:...
🌐
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....
🌐
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....
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-continue-statement
Python Continue Statement - GeeksforGeeks
Python · i = 0 while i < 10: if i == 5: i += 1 # ensure the loop variable is incremented to avoid infinite loop continue print(i) i += 1 · Output · 0 1 2 3 4 6 7 8 9 · Explanation: When i == 5, the continue statement skips printing and jumps to the next iteration.
Published   2 weeks ago
🌐
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 ...
🌐
Real Python
realpython.com › python-while-loop
Python while Loops: Repeating Tasks Conditionally – Real Python
March 3, 2025 - while is a Python keyword used to initiate a loop that repeats a block of code as long as a condition is true. A while loop works by evaluating a condition at the start of each iteration.
🌐
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, ...
🌐
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.
🌐
Tutorialspoint
tutorialspoint.com › python › python_continue_statement.htm
Python - Continue Statement
Python continue statement is used with 'for' loops as well as 'while' loops to skip the execution of the current iteration and transfer the program's control to the next iteration.
🌐
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…
🌐
IONOS
ionos.com › digital guide › websites › web development › python break continue
How to use Python break and continue - IONOS
July 13, 2023 - Python break and Python continue allow you to terminate or interrupt a loop. These commands often work in con­junc­tion with an “if” statement. Python while loops and Python for loops are well known among internet pro­gram­ming languages. They allow users to au­to­mat­i­cal­ly ...
🌐
Real Python
realpython.com › python-continue
Skip Ahead in Loops With Python's continue Keyword – Real Python
March 27, 2025 - In a while loop, continue transfers control back to the condition at the top of the loop. If that condition is True, then the loop body will run again. If it’s False, then the loop ends.
🌐
Unstop
unstop.com › home › blog › python break and continue statements explained with examples
Python Break And Continue Statements Explained With Examples
October 18, 2024 - The break statement terminates the nearest enclosing loop, while continue skips the current iteration and proceeds to the next one. Both are used to control loop execution based on specific conditions.
🌐
Python Tutorial
pythontutorial.net › home › python basics › python continue
Using Python continue Statement to Control the Loops
March 26, 2025 - # print the odd numbers counter = 0 while counter < 10: counter += 1 if not counter % 2: continue print(counter)Code language: Python (python)
🌐
Learn Python
learnpython.dev › 02-introduction-to-python › 110-control-statements-looping › 40-break-continue
break, continue, and return :: Learn Python by Nina Zakharenko
>>> for name in names: ... if name != "Nina": ... continue ... print(f"Hello, {name}") ... Hello, Nina ... # Python file names.py names = ["Jimmy", "Rose", "Max", "Nina", "Phillip"] for name in names: if len(name) != 4: continue print(f"Hello, {name}") if name == "Nina": break print("Done!")