FAQ: Introduction to Functions - Multiple Return Values

How can I make my variables low and high dynamic?

def get_boundaries(target, margin):
  low_limit = target - margin
  high_limit = margin + target

  return low_limit, high_limit

print(get_boundaries(100, 20))
low = 80
high = 120

By making them the return values. The function returns a tuple that you can unpack at the caller.

a, b = foo(u, v)
1 Like