python-retorno-funcion

Return values of functions in Python

  • 2 min

Function return values are a value that the function can return (optionally) as a result after performing its operations.

Return values allow functions to perform calculations and operations, and then pass the result back to the code that called them.

If you want to learn more, check out the Introduction to Programming Course

Return Syntax

In Python, the return statement is used to return a value from a function to the point from which the function was called.

When the return statement is encountered, the execution of the function stops and the value specified after return is returned as the function’s result.

The basic syntax of return is as follows:

def function_name(parameters):
    # function code block
    return value_to_return
Copied!

Practical Examples