Python def Keyword
Example
Create and execute a function:
def my_function():
print("Hello from a function")
my_function()
Try it Yourself »
Definition and Usage
The def
keyword is used to create, (or
define) a function.
Related Pages
Read more about functions in our Python Functions Tutorial.