python

Create a function in python

def function_name():
    print("Hello this is a function")

#To call the above function use
function_name()
Output
Hello this is a function

You can create a function in python by using the 'def' keyword before the function name. The above code snippet function will print - Hello this is a function when called. You can also use the function to return some values or data when called.

Was this helpful?