0

I have this code:

choose = ""
while choose != "x" or choose != "X" or choose != "o" or choose != "O":
    choose = input("X or O? -> ")

but it continues even if the user insert x, X, o or O.

I am new at coding, anyone have an idea to make it work?

Gino_P
  • 74
  • 7

2 Answers2

4

Try this

while choose not in [ "x" , "X" , "o" ,"O"]:

Any of 4 condition becoming true continues the loop. You can use 'and' insted of 'or'.

Instead, try using 'in', 'not in' keywords of Python.

Roshan Birar
  • 151
  • 1
  • 3
0

the logic combination is not what you want. [enter image description here][1] if you input O for choose, the condition choose != "x" is true, then while loops.

I guess what you want is:

    choose = ""
    while not(choose == "x" or choose == "X" or choose == "o" or choose == "O"):
        choose = input("X or O? -> ")

it works~/:D