def gcd(x, y):
while(y): x, y = y, x % y
return x
The function above returns the greatest common divisor of two numbers.
Why is y used as the condition in the while loop?
>Solution :
The expression in a while statement will be evaluated as a boolean. An integer of 0 will evaluate to False, everything else will evaluate to True.
Your statement is equivalent to while y != 0: