OneBite.Dev - Coding blog in a bite size

declare a void function without return value in python

Code snippet on how to declare a void function without return value in python

  def my_function():
    # code goes here

The code above shows how to declare a void function without return value in Python. A void function is a function that performs certain operations but does not return a value. The keyword “def” is used to declare the function, followed by the function name. Then, a pair of parenthesis is added with any parameters the function will take if needed. This is followed by a colon that signals the start of the code. Finally, the code that is executed when the function is called goes inside the block of code. The code indented within the block will only be executed once the function is called.

python