- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- 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.
Use the pass statement to write an empty function in Python −
# 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 −
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 −
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 find the first empty row of an excel file in Python?
- How to delete only empty folders in Python?