×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

Python Programs

Python continue Statement

Last Updated : April 22, 2025

Like other programming languages, in Python, the continue statement is used to continue the loop executing by skipping rest of the statement written after the continue statement in a loop.

The continue statement does not terminate the loop execution, it skips the current iteration of the loop and continues the loop execution.

Syntax

Below is the syntax of the continue statement:

continue

# Within the conditon inside a loop
if condition:
    continue

To understand the use of the continue statement, practice these examples.

Using continue in a For Loop

Here, we are printing the serious of numbers from 1 to 10 and continuing the loop if counter’s value is equal to 7 (without printing it).

# python example of continue statement

counter = 1

# loop for 1 to 10
# terminate if counter == 7

while counter<=10:
  if counter == 7:
    counter += 1 #increasing the counter
    continue
  print(counter)
  counter += 1

print("outside of the loop")

Output

1 
2 
3 
4 
5 
6 
8 
9 
10
outside of the loop 

Using continue in a For Loop with String

Here, we are printing the characters of a string and continuing the loop to print of the characters if the character is not an alphabet.

# python example of continue statement

string = "IncludeHelp.Com"

# terminate the loop if 
# any character is not an alphabet 

for ch in string:
    if not((ch>='A' and ch<='Z') or (ch>='a' and ch<='z')):
      continue
    print(ch)

print("outside of the loop")

Output

I
n
c
l
u
d
e
H
e
l
p
C
o
m
outside of the loop

Python Continue Statement Exercise

Select the correct option to complete each statement about the continue statement in Python.

  1. The continue statement is used to ___ the current iteration of a loop and proceed to the next iteration.
  2. The continue statement can be used in both ___ and while loops in Python.
  3. The continue statement will ___ the loop and move to the next iteration, skipping the remaining code in the current iteration.

Advertisement
Advertisement

Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.