Learn Python - Python tutorial - Pass Arguments Python - Python examples - Python programs
In C/C++ and Java, we can write empty function as following
python - Sample - python code :
// An empty function in C/C++/Java void fun() { }
In Python, if we write something like following in Python, it would produce compiler error.
python - Sample - python code :
python tutorial - 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.
python - Sample - python code :
We can use pass in empty while statement also.
python - Sample - python code :
We can use pass in empty if else statements.
python - Sample - python code :