Apr-14-2022, 09:52 AM
Hey, so I've got this piece of code that I put together that is pretty simple. However, when I execute the code it executes all the if statements instead of one. I know it has to be something wrong with my if statements, but I don't know what. Changing it to an elif doesn't help me. Any help would be appreciated. Thanks!
first_number = input("First Number: ") first_number = int(first_number) operator = input("Operation: ") second_number = input("Second Number: ") second_number = int(second_number) for sign in operator: if sign == "*" or "x" or "multiply" or "times": print(first_number * second_number) if sign == "/" or "divide": print(first_number / second_number) if sign == "+" or "plus" or "add": print(first_number + second_number) if sign == "-" or "minus" or "subtract": print(first_number - second_number)Also, if there's an easier solution to what I've made please let me know. Thanks!