Function to return two values in python [closed]

You can do that simply by:

def foo(start):
    end = start + 10
    return start, end

a, b = foo(100)
print(a,b)
#Output: 100 110

Here start is an integer, but if start is an array then:

def foo(start):
    result = []
    for s in start:
        result.append((s,s+ 10))
    return result

result = foo([1,2,3,4,5])
for a,b in result:
     print(a,b)

#Output: 
1 11
2 12
3 13
4 14
5 15

Leave a Comment