Return multiple values

A return statement can return multiple values as tuple, list, dictionary, and set.
You can specify the multiple values with comma.

Example:

def calculator(a, b):
    return a + b, a – b, a * b, a % b
result = calculator(20, 5)
print(“Add:”+result[0])
print(“Subtract:”+result[1])
print(“Multiplication:”+result[2])
print(“Division:”+result[3])


Related Tutorials