-3

I would like to know why my if else statement is not with the two inputs I added and I would like to know how to fix it

x = input('Please enter number')
y = input('Please enter another number')
if x + y > 5:
  print ('greater than')
elif x + y < 5:
  print ('less than')
elif x + y == 5:
  print ('equal to')
LH Alpha
  • 1
  • 1

2 Answers2

0

input returns a string. You want to convert to int with int(input(...)). Altogether we get:

x = int(input('Please enter number'))
y = int(input('Please enter another number'))
if x + y > 5:
  print ('greater than')
elif x + y < 5:
  print ('less than')
elif x + y == 5:
  print ('equal to')
Addison Schmidt
  • 374
  • 1
  • 7
0

Your code is not working because python is taking the input from the user as a string not an integer, so it doesn't work because you can't perform mathematical operations on strings

The Code:

x = int(input('Please enter number'))
y = int(input('Please enter another number'))
if x + y > 5:
  print ('greater than')
elif x + y < 5:
  print ('less than')
elif x + y == 5:
  print ('equal to')