Join our newsletter for the latest updates.

Python Program to Return Multiple Values From a Function

In this example, you will learn to return multiple values from a function.

To understand this example, you should have the knowledge of the following Python programming topics:

Example 1: Return values using comma

def name():
    return "John","Armin"

# print the tuple with the returned values

# get the individual items
name_1, name_2 = name()
print(name_1, name_2)


('John', 'Armin')
John Armin

When you return multiple values using comma(s), they are returned in the form of a tuple.

Example 2: Using a dictionary

def name():
    n1 = "John"
    n2 = "Armin"

    return {1:n1, 2:n2}

names = name()


{1: 'John', 2: 'Armin'}

When you return values using a dictionary, it is easy for you to keep track of the returned values using the keys.