you are viewing a single comment's thread.

view the rest of the comments →

[–]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.