FAQ: Introduction to Functions - Multiple Return Values


I was also a little bit confused by that. Actually, I suppose that what made it more difficult for me to fully clarify the multiple return values context at the specific exersice with boundaries, was the repeating use of the words “low” and “high” in the code.
To keep its simplier and more clear , I tried to use letters. At least for me, this way quite helpful .The output was of course the same. For example:

def get_boundaries(target, margin):
L = target - margin
H = target + margin
return L, H

A,B = get_boundaries(100, 20)

#we added this print statement just to sanity-check our solution:
print("Low limit: “+str(A)+”, High limit: "+str(B))

In fact, by “A” I name the first call of the function which corresponds to the first return value “L” i.e. the first calculation (subtraction).
By “B” I name the second call of the function which corresponds to the second return value “H” i.e. the second calculation (addition).