0

I just started with python, I tried to make 2 loops: first loop to be sure that the client enter the right entry; the other loop to resolve the calculation variables. But all the time I get "Unknown Entry"

OperationSelected = False
UnKnownEntry = False

while OperationSelected == False or UnKnownEntry == True:
    try:
        operation = input("Select operation to perform:\r\n1>PLUS\r\n2>MINU\r\n3>MULTIP\r\n4>DIVIDE\r\n>>> ")

        if operation != "1" or operation != "2" or operation != "3" or operation != "4":
            print("--------------------------")
            print("Unknown entry. ( " + operation + " )")
            print("--------------------------")
            UnKnownEntry == True
        else: 
            print("TEST")
            OperationSelected = True
            UnKnownEntry = False

    except Exception as e:
        print(e)
        break

while OperationSelected == True and UnKnownEntry == False:
    try:    
        num1 = input("Enter first number: ")
        num2 = input("Enter second number: ")
        
        if operation == "1":
            print("--------------------------------------")
            print("The Sulotion is: " + str(float(num1) + float(num2)))
            print("--------------------------------------")
        elif operation == "2":
                print("--------------------------------------")
                print("The Sulotion is: " + str(float(num1) - float(num2)))
                print("--------------------------------------")
        elif operation == "3":
            print("--------------------------------------")
            print("The Sulotion is: " + str(float(num1) * float(num2)))
            print("--------------------------------------")
        elif operation == "4":
            print("--------------------------------------")
            print("The Sulotion is: " + str(float(num1) / float(num2)))
            print("--------------------------------------")
    except Exception as e:
        print(e)
        break
rookie
  • 126
  • 10
  • Welcome to Stack Overflow. For future reference, please read [ask] and the [formatting help](https://stackoverflow.com/help/formatting) and make sure your code appears exactly as you actually have it (especially for Python). Please also note that this is *not a discussion forum*; we don't care about your level of experience as a programmer - we *do* care about you asking a *specific* question, *clearly*. – Karl Knechtel Nov 25 '21 at 16:54
  • That said, I was able to figure out what you meant, and it's a very common problem. Please see the linked duplicate for help. – Karl Knechtel Nov 25 '21 at 16:54
  • `if operation != "1" or operation != "2" or ...` If the user enters 1, then `operation != "2"` is true. If the user enters 2, then `operation != "1"` is true. You need to use `and` instead of `or`. – John Gordon Nov 26 '21 at 00:30

0 Answers0