If you have ever wanted to skip one turn of a loop without stopping the whole loop, you are looking for continue. Here you will see what it does in a plain for loop and a while loop, how it differs from break and pass, what happens with nested loops and with a loop else, and one while foot-gun that catches a lot of people. The page is short on purpose so you can try the examples as you read.
When you want the official wording, open the Python language reference for continue: it says continue proceeds to the next iteration of the nearest enclosing loop, or to the loop’s else when there is no next item. If you are still getting comfortable with loops themselves, skim the while loop tutorial next.
Tested on: Python 3.13.3; kernel 6.14.0-37-generic.
What does continue do in Python?
Think of one lap around a track. continue means “stop the rest of this lap, start the next lap.” It does not mean “leave the stadium”; that is what break does. Only the lines below continue in the same iteration are skipped; the loop keeps running.
Try this in your head (or in the REPL): when number is 3, you skip print, but you still move on to 4 and 5.
for number in range(1, 6):
if number == 3:
continue
print(number)You should see 1, 2, 4, and 5 on separate lines—notice 3 never prints.
Python continue syntax
You write the keyword on its own line:
continueYou can only use it inside a for or while loop. If you put it at the top level of a file, Python raises SyntaxError, which matches the rule above.
continue in a for loop
Inside a for loop, after continue Python grabs the next value from whatever you are iterating over and runs the body again from the top.
Suppose you want to print every country except one—you still visit "China" in the loop, you just skip the print for that pass.
countries = ["India", "Nepal", "Sri Lanka", "China", "Australia"]
for country in countries:
if country == "China":
continue
print(country)You get India, Nepal, Sri Lanka, and Australia, each on its own line.
continue in a while loop
With a while loop, after continue Python jumps back and checks the while condition again. That means you still need to update whatever drives that condition, or you can spin forever (there is a concrete example in Common mistakes).
Here multiples of 5 are skipped, but i still moves forward on every path so the loop can finish.
i = 1
while i <= 10:
if i % 5 == 0:
i += 1
continue
print(i)
i += 1You should see 1 through 4, then 6 through 9—no 5 or 10 in the output.
continue with if condition
There is no special continue keyword for if; you almost always tuck continue under an if so you only skip some passes. If you already use if / else, this is the same idea.
for n in range(5):
if n % 2 == 0:
continue
print(n)Here you only print odd numbers (1 and 3). If the body is tiny, some people prefer if n % 2 != 0: print(n) instead of continue; pick whichever reads better to you.
continue vs break in Python
When you are learning, keep this table nearby:
| Statement | What it does for you |
|---|---|
continue |
Skips the rest of this iteration and starts the next one in the same loop |
break |
Stops the whole loop and jumps to the code after the loop |
pass |
Does nothing; handy placeholder where Python needs a statement |
If you are also learning when a loop else runs, the Python break statement article walks through how break interacts with that else.
continue vs pass in Python
pass is a no-op: execution keeps moving down the same iteration. continue jumps straight to the next iteration, so anything below it in the body for this pass does not run.
First, with pass—you still print every number:
for number in range(1, 4):
if number == 2:
pass
print(number)You should see 1, then 2, then 3.
Now swap in continue—2 never reaches print:
for number in range(1, 4):
if number == 2:
continue
print(number)You should see 1, then 3.
continue in nested loops
When loops nest, continue only affects the innermost loop that wraps it. If you are in an inner for inside an outer for, your continue applies to the inner one.
for row in range(3):
for col in range(3):
if col == 1:
continue
print(row, col, end=" ")
print()Whenever col is 1, you skip printing for that column only; the outer row loop still advances as normal.
continue with loop else clause
You can attach an else to a for or while. That else runs when the loop finishes without hitting break. The tutorial is clear: continue does not cancel that else—it only skips the tail of the current iteration. If you never break, you still get the else after the last item.
for n in range(3):
if n == 1:
continue
print(n)
else:
print("loop else: finished without break")You should see 0, then 2, then the message from the else block.
Common mistakes with continue
Here are the mix-ups I see most often:
- You think
continueexits the loop—it does not; onlybreakdoes. - In a
whileloop, you hitcontinuebefore you change the variable that thewhileline depends on, so the condition never becomes false (infinite loop). - You use
continueoutside any loop and getSyntaxError. - You stack many
continuebranches when one straightforwardifwould read easier. - You assume
continueskips the loopelse; it does not—onlybreakchanges that story. - You treat
passlikecontinue; rememberpassdoes not skip the rest of the body.
Infinite while with continue
This pattern hangs because when i is 2, you never reach i += 1, so i stays 2 forever:
# Bug: when i == 2, continue skips i += 1, so i stays 2 forever
i = 0
while i < 5:
if i == 2:
continue
print(i)
i += 1Do not run that snippet as-is in a REPL unless you are ready to interrupt it.
Safer pattern
Bump your counter (or otherwise make progress) before you continue, or restructure so the update cannot be skipped:
i = 0
while i < 5:
i += 1
if i == 2:
continue
print(i)You should see 1, 3, 4, 5—each on its own line.
Python continue quick reference table
| What you want | What to write |
|---|---|
| Skip the rest of this iteration, keep looping | continue |
| Stop the loop completely | break |
| Placeholder that does nothing | pass |
| Skip only when a condition holds | if cond: continue |
Which loop does continue affect? |
The innermost for or while around it |
Does continue skip loop else? |
No—only break changes whether else runs |
Summary
You use continue when you want to abandon the rest of this lap around a for or while, but you still want the loop itself to keep going. It is not break, it is not pass, and it does not trick Python into skipping a loop else if the loop finishes normally. In while loops, always ask yourself whether the line that moves you toward exit still runs on every path—including paths where you hit continue. When you are ready to pair this with leaving loops early, read the break statement guide next.

