Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

1 Answer
Maheshwari Thakur

In python, we can write an empty function or statements by using the ‘pass” statement. Writing a pass statement does nothing and is simply used to avoid compile errors while writing an empty function.

Empty function in python:
#Empty function in Python
def empty_func():
pass

Above code statements are little different than other popular programming languages like C,C++ or Java.

#An empty function in C/C++/Java
void func()
{
}

Empty loop in Python

We can write an empty loop, using “pass” statement -

#Empty loop in Python
condition = True
while (condition == True):
   pass

Similarly we can empty conditional statement (if/else) using “pass” statement -

condition = True
if(condition == True):
   pass
else:
   print("Error")

Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.