Functions can return multiple values by returning a tuple:
def min_max(numbers):
return min(numbers), max(numbers)
smallest, largest = min_max([3, 1, 4, 1, 5])
# smallest is 1, largest is 5
The function returns a tuple (1, 5), and unpacking assigns each element to a variable. This is cleaner than returning a list or dictionary.
Many Python built-in functions use this pattern. divmod(17, 5) returns (3, 2) for quotient and remainder.