Python Pass Statement – POFTUT

Python Pass Statement


Python provides different keywords which do not exists in other programming languages.  pass is one of the original keyword used for  nothing. pass keyword is a requirement for python block specification and syntax.

Why To pass?

Other languages generally uses some block specifier like {} or ;  etc. For example we can define functions but if we do not provide the body this may create some conflicts. So we need some statement which will provide nothing and null for the body.

def call():
   pass

if(a==1):
   pass
elif(a==2):
   print("OK")

In this example we can see that pass is used in two place. In the first place we defined the call function body with pass . This will give us the ability to define function without a body

In the second place we use pass in the first condition of if-else statement. We simply pass the first condition.

LEARN MORE  Javascript Decision Making with If-Else

Leave a Comment