Python pass statement
The pass statement is a null statement. But the difference between pass and comment is that comment is ignored by the interpreter whereas pass is not ignored.
The pass statement is generally used as a placeholder i.e. when the user does not know what code to write. So user simply places pass at that line. Sometimes, pass is used when the user doesn’t want any code to execute. So user simply places pass there as empty code is not allowed in loops, function definitions, class definitions, or in if statements. So using pass statement user avoids this error.
Syntax:
pass
Example:
i = 0
while i < 5:
if i == 3:
i += 1
pass
else:
print(i)
i += 1
output:
0
1
2
4