Skip to content

Python if continue | Example code

  • by

The if continue statement is used in both whiles and for loops in Python. A continue statement does not execute all the remaining statements in the current iteration of the loop and moves the control back to the top of the loop.

Python if continue examples

Simple example code. If using the continue statement in Python loops then it returns the control to the beginning of the loop.

for i in range(5):
    if i == 3:  # skips if i is 3


Python if continue

Another Example code

If continue statement with NumPy in Python.

import numpy as np

values = np.arange(0, 10)
for value in values:
    if value == 3:
    elif value == 8:
        print('Eight value')
    elif value == 9:

Output: Eight value

Python while continue

If the program execution reaches a continue statement, the program execution immediately jumps back to the start of the loop.

while True:
    print('Who are you?')
    name = input()
    if name != 'Joe':
    print('Hello, Joe. What is the password?')
    password = input()
    if password == '123456':
print('Access granted.')


Python if continue Example code

Do comment if you have any doubts or suggestions on this Pytho it statement with the continue keyword.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

Your email address will not be published. Required fields are marked *