Issue with python max number function

Question:

In the course I follow he made an example like this and when I applied it worked just fine but then when I added the input part myself it doesn’t give out the max number correctly.

def max_num(num1, num2, num3):
    if num1 >= num2 and num1 >= num3:
        return num1
    elif num2 >= num1 and num2 >= num3:
        return num2
    else:
        return num3


first = input('first number ')
second = input('second number ')
third = input('third number ')
print(max_num(first, second, third))

Answers:

Python’s input() function returns a String (https://docs.python.org/3/library/functions.html#input)

You need to convert the number to int or float:

number = int(input('number '))
Answered By: svfat
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.