In C/C++ and Java, we can write empty function as following
// An empty function in C/C++/Java void fun() { }
In Python, if we write something like following in Python, it would produce compiler error.
# Incorrect empty function in Python def fun():
Output :
IndentationError: expected an indented block
In Python, to write empty functions, we use pass statement. pass is a special statement in Python that does nothing. It only works as a dummy statement.
# Correct way of writing empty function # in Python def fun(): pass
We can use pass in empty if else statements.
# Empty in if/else in Python mutex = True if (mutex == True) : pass else : print("False")
Australia
UK
UAE
Singapore
Canada
New
Zealand
Malaysia
USA
India
South
Africa
Ireland
Saudi
Arab
Qatar
Kuwait
Hongkong
Copyright 2016-2023 www.programmingshark.com - All Rights Reserved.
Disclaimer : Any type of help and guidance service given by us is just for reference purpose. We never ask any of our clients to submit our solution guide as it is, anywhere.