Advanced Python Code Challenges : Control Flow

Create a function called `max_num()` that has three parameters named `num1` , `num2` , and `num3` .
The function should return the largest of these three numbers. If any of two numbers tie as the largest, you should return `"It's a tie!"` .

def max_num(num1,num2,num3):

if num1>num2 and num1>num3:

``````return num1
``````

elif num2>num1 and num2>num3:

``````return num2
``````

elif num3>num1 and num3>2:

``````return num3
``````

elif num1==num2:

``````return "It's a tie!"
``````

elif num1==num3:

``````return "It's a tie!"
``````

elif num2==num3 and (num1 > num2 or num1 < num2):

``````return "It's a tie!"
``````

Uncomment these function calls to test your max_num function:

print(max_num(-10, 0, 10))

should print 10

print(max_num(-10, 5, -30))

should print 5

print(max_num(-5, -10, -10))

should print -5

print(max_num(2, 3, 3))

should print “It’s a tie!”

However I am not able to print 'Its a tie".I would be grateful if someone helps me out.

Hello! Could you provide some more information on what happens when you run the code?

If between the three numbers, any one number is greater then it gives that number as output.
E.g between 1,2,3 gives output as 3
Also between -1,1,0 it gives output as 1 which is correct

However when between 2,3,3 it should give ‘Its a tie’ as output but it gives output as 3.

Hello @siddhanthshah6643761 and welcome to the Codecademy Forums!

Take a closer look at this line of code. What’s wrong here that could be causing `max_num(2, 3, 3)` to return `3`?