- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to write an empty function in Python?
In this article, we will see how we can create an empty functions in Python. A function is a block of organized, reusable code that is used to perform a single, related action. Functions provide better modularity for your application and a high degree of code reusing.
Function blocks begin with the keyword def followed by the function name and parentheses ( ( ) ). Here, we will see examples of Empty Functions.
Empty Function
Use the pass statement to write an empty function in Python −
Example
# Empty function in Python def demo(): pass
Above, we have created an empty function demo().
Empty if-else Statement
The pass statement can be used in an empty if-else statements −
Example
a = True if (a == True) : pass else : print("False")
Above, we have created an empty if-else statement.
Empty while Loop
The pass statement can also be used in an empty while loop −
Example
cond = True while(cond == True): pass
Above, we have created and empty while loop.
- Related Articles
- How to write an empty function in Java
- How to create an empty list in Python?
- How to create an empty class in Python?
- How to create an empty dictionary in Python?
- How to create an empty tuple in Python?
- How to write a recursive function in Python?
- How to create an empty file using Python?
- How to create an empty Figure with Matplotlib in Python?
- How to write recursive Python Function to find factorial?
- How to write a function to get the time spent in each function in Python?
- How to empty an array in Java
- How to empty an array in JavaScript?
- In Javascript how to empty an array
- How to find the first empty row of an excel file in Python?
- How to delete only empty folders in Python?

Advertisements