0

sorry if this is a bad question.

I am trying to create a simple tic-tac-toe game.

First, I want to have the user choose either X or O and verify they entered one of these letters. Below is my attempt to do that. I am encountering the issue that the while loop is still running even thought the user entered a X or an O.

There is probably another way to solve this but I am hoping to figure out why this isn't working. Since I can't figure it out it means I am misunderstanding some concepts and I would like to understand them.

def XorO():
    
    response = input('Would you like to be X or O?')
    

    while response != 'X' or 'O':
        print("Please input either X or O")
        response = input('Would you like to be X or O?')

Thank you!

Adrus
  • 1
  • 2
    potentially because `!=` is executed before `or` and the logical value of `'O'` is `True` – Alex Sep 11 '22 at 21:20
  • show confidence in your questions when you ask them -- there's no bad question as long as you've searched the rest of stackoverflow for other questions like it and you've looked online for an answer and didn't find anything – CR130 Sep 11 '22 at 21:28

0 Answers0