THE WORLD'S LARGEST WEB DEVELOPER SITE

Python def Keyword

❮ Python Keywords


Example

Create and execute a function:

def my_function():
  print("Hello from a function")

my_function()
Run example »

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.


❮ Python Keywords