Skip to content

How to create a function in Python

Functions within our python scripts are created using the ‘def’ command:

def functionName():
	FunctionContents

Notice that once again we use indentation to represent scope, so everything inside this function will be indented.

Lets break down the function:

def = Define

functionName = The name of the function

() = The parameters the function will take

Published inPyCharmPythonscripting