Programming with Python

  1. Home
  2. Docs
  3. Programming with Python
  4. Control statement in python
  5. Use of pass in python

Use of pass in python

The simplest statement is the empty statement i.e., a statement which does nothing. In python an empty statement is pass statement.

Whenever the python encounters a pass statement, python does nothing and move to next statement in the flow of control.

A pass statement is useful in those instances where the syntax of the language requires the presence of a statement but where the logic of the program does not.

syntax:-

for variable in sequence:
     pass

e.g.,

l =['A', 'B', 'C', 'D', 'E'] 
for i in l: 
	if(i =='A'): 
		pass
	else: 
		print(i)
output-
B
C
D
E

This is all about pass statement in python.

Was this article helpful to you? Yes No

How can we help?