-2

for some reason when I type "exit" or "EXIT" the loop continues to iterate

I tried breaking using variables and the break statement

obj = 1
while obj != None:
    a = input("enter a number:\n")
    b = input("enter a number:\n")
    try:
        int(a)
        int(b)
        print("succes!")
    except ValueError:
        print("you didnt enterd numbers")
        continue
    print("what do yo want to do?\n")
    donxt = input("for exit the program type EXIT, to continue tap CONTINUE:\n")
    if donxt == "continue" or "CONTINUE":
        continue
    elif donxt == "EXIT" or "exit":
        obj = None
ed gru
  • 3
  • 1

1 Answers1

3

You have if donxt == "continue" or "CONTINUE"

This is actually if (donxt == "continue") or ("CONTINUE") not if (donxt == "continue") or (donxt == "CONTINUE").

The "CONTINUE" always evaluates to true so (donxt == "continue") or ("CONTINUE") is always true.

You want to do: if (donxt == "continue") or (donxt == "CONTINUE")

Ahmed
  • 120
  • 6