Pass statement in Python language
In this tutorial, we will discuss the concept of pass statement in Python language.
In the Python programming language, the pass is a keyword(statements) that is used to indicate when nothing happens – the loops(for, while), function and class are empty.
Syntex
Syntex of the pass statements
pass
We can use pass statement to indicate a null block or it can be used to quickly add items that are in the unimplemented block in python.
Example 1
Display error message
When we executed the above code, it produced the following results.
No error but no output.
Example 2
When we executed the above code, it produced the following results.
No error but no output
Example 3
Display of error message
When we executed the above code, it produced the following results
No error but no output
Display error message
When we executed the above code, it produced the following results
No error but no output
Some example programs with pass
Program 1
When we executed the above program, it produced the following results
number is:1
number is:2
number is:3
number is:4
number is:5
number is:6
number is:7
number is:8
number is:9
number is:10
Exit from loop
Program 2
When we executed the above program, it produced the following results