0

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))
  • 4
    Your numbers are still strings, not numbers (integers or floats). `input()` returns a string. And strings compare differently than numbers ("12" < "8" for strings). – 9769953 Jul 13 '22 at 08:47

1 Answers1

0

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 '))
svfat
  • 3,273
  • 1
  • 15
  • 34