Difference between pass and continue in Python

This article is created to clear all your doubt on the two conditional statements of Python language, that are pass and continue statement. I'm sure, after understanding all the things provided here, you'll get the complete knowledge about these two statements or keywords.

pass Vs continue

The table given below differentiates pass and continue statements of Python programming language:

pass continue
does nothing jumps for next iteration
required when syntactically needed but practically not required when want to skip the execution of remaining statement(s) inside the loop for current iteration
can be used as a placeholder for future code can not be used as a placeholder for future code

pass Vs continue Example

Example helps a lot in understanding the topic of any computer programming language like Python. Therefore here also, I've created an example, that easily shows you the difference between these two statements:

nums = [1, 2, 3, 4, 5]

print("----Using \"pass\"-------")
for n in nums:
    if n == 3:

print("----Using \"continue\"-------")
for n in nums:
    if n == 3:

This program produces following output:

pass vs continue python

As you can see from the above output, the pass statement does nothing, whereas the continue statement skip the execution of remaining statement, that is, continue jumps for the next iteration, whereas pass does not.

Python Online Test

« Previous Tutorial Next Tutorial »

Follow/Like Us on Facebook

Subscribe Us on YouTube