What is the syntax to define a function?

def <function name>(<parameters>):
     "<optional documentation of function, called docstring>"
     <your function code here>
     return <what to return>
#examples
def printString(str):
     "Prints whatever string is passed here"
     print(str)
     return

 

 

Advertisements