Module 6

return

Getting a value back from a function.

Sending a value back

The return statement sends a value back to the code that called the function. The function stops when it reaches return.

Python
def add(a, b):
    return a + b

result = add(3, 4)
print(result)
7
Your task

Return a value

  • Define add(a, b) that returns a + b. Print add(3, 4).