Python Program - Return Multiple Values From a Function

In Python, you can return multiple values from a function by returning them as a tuple. Here's an example program:

refer‮igi:ot ‬ftidea.com
def get_name_and_age():
    name = input("Enter your name: ")
    age = int(input("Enter your age: "))
    return name, age

name, age = get_name_and_age()
print("Your name is", name)
print("Your age is", age)

In this program, the get_name_and_age function prompts the user to enter their name and age, then returns them as a tuple. The main program calls the function and unpacks the tuple into name and age variables. Finally, the program prints out the values.