September 2026
1051 pages
35h 4m
English
During the development of a program, it can happen that at a certain point in time, a control structure is only partially implemented. The programmer creates a statement header but doesn’t add a statement body because they may want to take care of other, more important things first. However, a statement header hanging in the air without a corresponding body is a syntax error.
For this purpose, you can use the pass statement—a statement that does nothing at all. It can be applied as follows:
if x == 1: passelif x == 2: print("x has value 2")
In this case, only pass is found in the body of the if statement. Thus, if x has the value 1, nothing’s going to happen.
The purpose of the pass statement is to avoid syntax errors ...
Read now
Unlock full access