How to return 3 values from a function in Python

2 Answers

0 votes
def f(n):
    a = n * 2
    b = n * 3
    c = n * 4
    return a, b, c
 

result = f(12)
 
print(result)
 
x = result[0]
y = result[1]
z = result[2]
 
print(x)
print(y)
print(z)
 
 
 
 
'''
run:
 
(24, 36, 48)
24
36
48
 
'''

 



answered Dec 17, 2021 by avibootz
0 votes
def f(n):
    a = n * 2
    b = n * 3
    c = n * 4
    return a, b, c
 

x, y, z = f(12)
 
print(x)
print(y)
print(z)
 
 
 
 
'''
run:
 
24
36
48
 
'''

 



answered Dec 17, 2021 by avibootz
...