Skip to content
Justice Tech School

Return Values

return sends a value back and ends the function. A function can return several values at once as a tuple, and you can unpack them. Without return, the function gives back None. The pass statement is a placeholder for an empty body.

Example
def min_max(nums):
    return min(nums), max(nums)

low, high = min_max([4, 9, 1, 7])
print(low, high)

def shout(text):
    print(text.upper())

result = shout("hi")
print(result)

def todo():
    pass

print(todo())

Result

1 9
HI
None
None

Exercise

Send a value back from the function.

def add(a, b):
     a + b

Quiz Test

How many values can a function return?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.