codescracker


python

Python continue Statement



« Previous Tutorial Next Tutorial »


Here you will learn about continue statement in python with its example.

The continue statement in python is used to jump back to the top of the loop.

The continue statement skip all the code written below the continue keyword or statement in the loop and jump back to the loop's condition part to update and/or update and check the condition again and comes back to the loop body.

Python continue Statement Example

Let's take an example shows how to use continue statement in python to skip the code written below as shown in the given program.

# Python continue Statement Example
print("Welcome to Python continue statement.");
count = 0;
while True:
    count += 1;
    if count>10:
        break;
    if count==5:
        continue;
    print(count);

Here is the sample output of above continue statement program.

python continue statement

As you can see from the above example, when the variable count holds the value 5 then the condition count==5 evaluates to be true and the continue statement run and goes to the top of the loop after skipping the code written below to that continue statement, that is, print(count) or 5. Therefore, you can check that 5 is missing from the above output screenshot.


« Previous Tutorial Next Tutorial »








Tools
Calculator

Quick Links
Signup - Login - Give Online Test