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)

Recommended Answers

All 3 Replies

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

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.