Continue Statement in Python with Example
top of page

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:





20 views0 comments

Recent Posts

See All

Tell function in python with example

Tell () function can be used to get the position of file handle and returns current position of file object where as Seek () function is used to change the position of the file handle to a given speci

Seek function in python with example

Seek () function is used to change the position of the file handle to a given specific position in python. File handle such as a cursor which defines from where the data has to be read or written in t

bottom of page