+ 1
Can someone plz correct my code?
I have a code that compare 3 inputs from the user. When the user inputs are: 666 777 888 The code works correctly. BUT !!!!!!! When the user inputs are: 666 777 14444 The code works crazy and don't do what it must do. This is my code: def max(x, y, s): if (x > y) and (x > s): return x elif (y > x) and (y > s): return y elif (s > x) and (s > y): return s i=input() q=input() e=input() print("You have entered:", i, "and", q, "and", e) print("The biggest one is:", float(max(i, q, e))) print("\n") print("Our numbers are:", max(36551452,5541225559,6560033219))
4 Respuestas
+ 6
Please write
i=int(input())
q=int(input())
e=int(input())
You are taking input as string so please change it in integer..you will get your desired output
+ 6
The issue is, that input() always returns everything in string format. So what you are doing is to compare numbers in string format. To make it work correctly, you can do this:
i = int(input))
...
So your variables now contain numerical values, and the result will be ok.
+ 3
Thank you RAJESH SAHU & Lothar very much. Problem solved 👍.
0
Share ur code bit