Python Pass Statement

In this tutorial, we will learn more about past statements. It is interpreted as a placeholder for future functions, classes, loops, and other operations.

What is Python's Pass Statement?

The pass statement is also known as the null statement. The Python mediator doesn't overlook a Remark, though a pass proclamation isn't. As a result, these two Python keywords are distinct.

We can use the pass statement as a placeholder when unsure of the code to provide. Therefore, the pass only needs to be placed on that line. The pass might be utilized when we wish no code to be executed. We can simply insert a pass in cases where empty code is prohibited, such as in loops, functions, class definitions, and if-else statements.

Syntax

Ordinarily, we use it as a perspective for what's to come.

Let's say we have an if-else statement or loop that we want to fill in the future but cannot. An empty body for the pass keyword would be grammatically incorrect. A mistake would be shown by the Python translator proposing to occupy the space. As a result, we use the pass statement to create a code block that does nothing.

An Illustration of the Pass Statement

Code

Output:

Not reached pass keyword:  Python
Not reached pass keyword:  Placeholder
Not reached pass keyword:  Statement

The same thing is also possible to create an empty function or a class.

Code


Next TopicPython Strings