Contol Flow Rational Operators II Challanges

In this code I have to write a function called greater_than that takes two integer inputs, x and y and returns the value that is greater. If x and y are equal, I should return the string “These numbers are the same”, but it keeps giving me an error saying that I am not doing this correctly, could someone please help me fix it? Thanks.

def greater_than(x,y):
  if x > y:
    print(x)
  if y > x:
    print(y)
  if x == y:
    print("These numbers are the same")
greater_than(5,5)

return and print() are not the same.

This PythonPrinciples article does a good job of explaining the difference. If the goal is to return the value, rather than print() it, you’ll need to replace your print() calls with return:

return "These numbers are the same"
3 Likes

Oh, thanks! It worked! :+1: