top of page
Writer's pictureRajesh Singh

Continue Statement in Python with Example

Updated: Feb 17, 2022


The continue statement is used within a loop to skip the rest of the statements in the body of loop for the current iteration and jump to the start of the loop for next iteration. The break and continue statements are opposite each other which are used to change the flow of loop, break terminates the loop when a condition is got and continue leave out the current iteration. The continue statement is used in both while and for loops. To contine in a loop we can use the continue keyword.

In other words we can say that the continue statement in python return the control to beginning of the control loop.

Syntax:

continue

Syntax for while loop:

while expression:

statement

if condition:

continue

statement

Syntax for for loop:

for value in range:

statement

if condition:

continue

statement


Flow diagram


Example:

program to display only odd numbers

for n in [10, 13, 9, 68, 4, 91, 54]:

if n%2 == 0:

continue

print(n)

Output:

13

9

91

Continue Statement in Python Video:





21 views0 comments

Recent Posts

See All

For Loop MCQs in Python

Q1. What is the output of the following Python code? x={1:"X",2:"Y",3:"Z"} for i,j in x.items():     print(i,j,end=" ") A.    1 X 2 Y 3 Z...

Comments


bottom of page