0
Help with basic python code
https://code.sololearn.com/cr8r3OSp2viU/?ref=app My code is giving weird outputs when I use 2- digit with 1- digit numbers. For example, it correctly returns "5 is greater than 4" but incorrectly returns "25 is less than 5". I think it has something to do with the input part but I am a total newbie, so I don't really know. Thanks!
1 Answer
+ 7
input() returns a string so you have to convert them to integers using int() function
x = int(input())
y = int(input())
if x < y:
print(x, 'is less than', y) #replaced '+' with ',' because '+' needs same types (you can use str(x) + 'is less than' too)
else:
print(x, 'is greater than', y)