+ 1

Why won't my program substract correctly?

Here it is, hope you can help me: print("Hi, select the calculation you want to make") print("Add or Substract") selection = input(":") if selection == "Add" or "add": x = int(input("Enter your first number: ")) y = int(input("Enter the second number: ")) print(x + y) elif selection == "Substract" or "substract": a = int(input("Enter your first number: ")) b = int(input("Enter the second number: ")) print(a - b) else: print("Unknown Command")

16th Nov 2016, 12:37 AM
Iván Baca
Iván Baca - avatar
2 Respuestas
+ 1
write your input and the result please
16th Nov 2016, 1:09 AM
Maurizio Urso
Maurizio Urso - avatar
+ 1
If I input Substract, then 5, and then 4 it gives me 9, I think that it executes the "add" lines instead of the "Substract" ones
16th Nov 2016, 1:20 PM
Iván Baca
Iván Baca - avatar