Tell us what’s happening:
Hey, hope it’s not too much of a bother but I’ve seen my return is print correctly for this project , but I can’t seem to find a way to make it return in a way that the challenge accepts it in python. I know I’m probably missing something just trivial but if you could let me know that would be amazing! Thank You!
Your code so far
def gcd(x, y):
if x>y:
z=x
if y>x:
z=y
else:
z=x
x_divisors = []
y_divisors = []
common_divisor = []
for integers in range(1,z,1):
if x%integers == 0:
x_divisors.append(str(integers))
for integers in range(1,z,1):
if y%integers == 0:
y_divisors.append(str(integers))
print( )
if len(y_divisors) >= len(x_divisors):
for divisor in y_divisors:
if divisor in x_divisors:
common_divisor.append(str(divisor))
else:
for divisor in x_divisors:
if divisor in y_divisors:
common_divisor.append(str(divisor))
greatest_common_divisor= max(common_divisor)
print(greatest_common_divisor)
return greatest_common_divisor
gcd(654, 456)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 Edg/142.0.0.0
Challenge Information:
Daily Coding Challenge - GCD
https://www.freecodecamp.org/learn/daily-coding-challenge/2025-11-15