I am creating a function to check x is greater than y, and if not it switches the two values and returns them.
def xGreater(x, y):
if(y > x):
x, y = y, x
return x, y
My query is what is the best way to go about using this function within another function, my current code is the following:
def gcd(x, y):
x , y = xGreater(x, y)
r = x % y
while(r != 0):
x, y = y, r
r = x % y
return y
Can I not simply call xGreater(x, y) to alter the values of x and y, without the x, y = in front? Or does this only work when there is a single variable being returned. Thanks!
ifandwhilestatements).func(a)can never change what the local namearefers to in the calling scope, regardless of what kind of value that name refers to.