return statement

The statement return expression, which ends a function call immediately and hands the value back to the caller.

In more detail

The caller can then store, print or compute with the value, as in total = sumList(nums). Printing is not returning: a function that only prints hands back None. A return inside a loop stops both the loop and the function.

Example

def square(x):
    return x * x

Related terms

Taught in

References

Certification courses