0

It will carry on if the input is X but not O!!

block of code concerning this matter

print("\nWould you like be X's or O's ? <O/X>:")
    human=["",""]
    while not (("X") or ("O")) in human[0]:
        human[0]=input("")

whole code:

print("Welcome to the greatest intelletual challenge of all time: Tic Tac Toe.")
print("This will be a showdown between your human brain and my silicon processor.\n")
board=["","","","","","","",""]
def display_board(board):
    print(board[1],"""                               |""",board[1],""" |""",board[3])
    print("""                            -------------""")
    print(board[1],"""                               |""",board[1],""" |""",board[3])
    print("""                            -------------""")
    print(board[1],"""                               |""",board[1],""" |""",board[3])
def instructions():
    print("You will make you move known by entering a number, 0 - 8. The number will correspond to the board posistion as illustrated:")
    display_board(board)
def settings(board):
    print("\nWould you like be X's or O's ? <O/X>:")
    human=["",""]
    while not (("X") or ("O")) in human[0]:
        human[0]=input("")
    if human==("X"):
        computer=["O",""]
    else:
        computer=["X",""]
    print("\nDo you require the first go? <Y/N>:")
    human[1]=input("")
    if human[1]==("Y"):
        computer[1]=("N")
    else:
        computer[1]=("Y")
instructions()
print("Prepare youself, human. The ultimate battle is about to begin.")
settings(board)

Edited by vegaseat: added code tags

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by ThePythonNoob
0

Edit the post and put all that code inside the code tags, it'll make it easier for others to help you.

0

Logic statements following the while are not always intuitive. I would code it this way ...

print("\nWould you like be X's or O's ? <O/X>:")
human=["",""]
while True:
    human[0]=raw_input("").upper()
    if human[0] == "X" or human[0] == "O":
        break

print(human) # for test only
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.