Python continue statement

The Continue statement in Python

The python continue statement is used to skip the current block of for loop or while loop. It will not execute the next statements and move the pointer to the beginning of the for or while loop.

Example of using continue with while loop

The example below will not display 3, because as soon as the variable i reaches the value=3 it will encounter the continue statement, where loop skips and move to the beginning of the while loop.

The output will be:

Current value: 2

Current value: 4

Current value: 5

The continue with for loop example

The following examples uses Python continue with the for loop. We placed the continue statement as the variable j value is ‘c’ in the loop.

See below:

Output will be:

a

b

d

You can see, the loop only displayed a,b and d.

Also see –  The For loop | while loop

Was this article helpful?

Related Articles

Leave A Comment?