Skip to content

Python for loop continue vs pass

  • by

The main difference between Python for loop continue vs pass is pass simply does nothing, while continue goes on with the next loop iteration.

Python for loop continue and pass

continue forces the loop to start at the next iteration while pass means “there is no code to execute here” and will continue through the remainder of the loop body.

Python for loop continue vs pass

A simple example code difference would become apparent if you added another statement after the if: After executing pass, this further statement would be executed. After continue, it wouldn’t.

a = [0, 1, 2]
for element in a:
    if not element:

for element in a:
    if not element:


Python for loop continue vs pass

Continue statement

This statement is used to skip over the execution part of the loop on a certain condition. After that, it transfers the control to the beginning of the loop.

Pass statement

As the name suggests pass statement simply does nothing. We use pass statements to write empty loops. Pass is also used for empty control statements, functions, and classes.

Do comment if you have any doubts or suggestions on this Python continue vs pass topic.

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 *