num1 = input("Please enter your first number: ") num2 = input("please enter your second number: ") op = input("PLease select your operation: ") while op != "-" or "/" or "+" or "*": if op == "*": a = float(num1)*float(num2) print(a) elif op == "/" : b = float(num1)/float(num2) print(b) elif op == "-": c = float(num1)-float(num2) print(c) elif op == "+": d = float(num1)+float(num2) print(d) else: print("Invalid") op = input("Please enter a valid operation: ")This is my code. I'm just trying to create a simple calculator. When I input *,/,+,- the program gives me an infinite loop. When i input anything other then *,/,+,- I don't get an infinite loop. Why is that?
Also,
I thought that if i set "op" equal to * or / or + or - the program wouldn't allow "op" to pass through the program, due to the condition "while op != "-" or "/" or "+" or "*":" but "op" clearly passes through.
Am I confused about how while loops work?
Thank you