0

I know I am being stupid but I am not sure how. For this program, the user must enter 1 or 2, 1 converts Inches to CM, and 2 converts CM to Inches.

Now the problem is, if they enter a number that is not equal to 1 or 2, it should display that error "Sorry, please enter either 1 or 2". Although the error message displays when the user doesn't enter 1 or 2, when I enter the correct inputs 1 or 2, it displays that error anyway.

Any solutions? Thanks

ask_user = int(input("Enter 1 to convert inches to centimetres or 2 to convert centimetres to inches: "))

#This is the error below, it prints this statement when you enter 1 or 2**
if ask_user != 1 or 2:
    print("Sorry, please enter either 1 or 2!")

if ask_user == 1:
    inch = int(input("Enter the amount of Inches you wish to convert to Centimeter: "))
    cm = inch * 2.54
    print(cm)

if ask_user == 2:
    cm = int(input("Enter the amount of Centimeter you wish to convert to Inch(s): "))
    inch = cm * 0.393701
    print(inch)
wanjo
  • 15
  • 4

1 Answers1

0
if ask_user != 1 and ask_user != 2:
    print("Sorry, please enter either 1 or 2!")
    return 
James
  • 332
  • 2
  • 3
  • 9