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
11
0
October 18, 2022
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
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 26, 2022
🌐
W3Schools
w3schools.com › python › ref_keyword_continue.asp
Python continue Keyword
Study Plan Python Interview Q&A Python Bootcamp Python 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....
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-continue-statement
Python Continue Statement - GeeksforGeeks
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
Published   1 month ago
🌐
Python documentation
docs.python.org › 3 › tutorial › controlflow.html
4. More Control Flow Tools — Python 3.14.4 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:...
🌐
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 ...
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.
🌐
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.
🌐
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.
🌐
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, ...
🌐
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......
🌐
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
🌐
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.
🌐
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) ... How it works. First, define the counter variable with an initial value of zero · Second, start the loop as long as the counter is less than 10.
🌐
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....
🌐
The Knowledge Academy
theknowledgeacademy.com › blog › python-while-loop
Python While Loop: Everything You Should Know
February 25, 2026 - 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.
🌐
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 - The continue keyword is used to skip the current rest of iteration process and proceed to the next iteration. When we use it in a loop, it immediately returns the control to the beginning of the loop and re-evaluate the loop’s condition.