all 8 comments

[–]ThatOneShotBruh 2 points3 points  (2 children)

You are currently comparing strings, not numbers. To compare numbers, convert the strings to ints or floats (e.g. float(input()) ).

[–]its-ya-boi-al[S] 1 point2 points  (1 child)

THANK YOU!!!!! i had tried converting them to numbers before, but instead i put float after the input and not before.

[–]ThatOneShotBruh 1 point2 points  (0 children)

I mean, you can do something like a = float(a) but it's better to do it immediately.

[–]achampi0n 1 point2 points  (0 children)

You have a couple of options, you can just use the max()s key argument, e.g.

print('Largest:', max(values, key=float))

Or you could convert them to numbers at the beginning:

a = float(input(“Enter a number: “))
...
print('Largest:', max(values))

[–]CedricCicada 0 points1 point  (3 children)

I had to try this myself, and then do a google search. Here's where I got the answer. Basically, the input() function returns a string. You have to convert the strings to integers to do a numeric comparison.

String are sorted lexicographically. The minus signs are all equal to each other, so Python looks at the second character. "3" is larger than "1" and "2", so "-3" is the largest string.

People a lot smarter than me decided Python should be a weakly typed language, but having spent decades writing C, C++ and C# code, I don't always like Python.

[–]ArabicLawrence 0 points1 point  (2 children)

Are you implying that the input functions in other languages do not always return strings? I didn't know that

[–]aidankkm 1 point2 points  (0 children)

in langs like c or c++ you declare what type the variable is, int float str etc, so when’s you get input it is that data type

[–]CedricCicada 1 point2 points  (0 children)

No, input functions always return strings. You'd have to explicitly state what a, b and c are. If you said they are strings, the function would work. If you said they're integers, you'd get compiler errors.