用户输入错误Python Tic Tac Toe

时间:2018-03-01 00:00:42

标签: python python-3.x input

我正在尝试将用户输入设为'X''O'。我一直在EOF when reading a line。我在下面粘贴了我的代码。

from IPython.display import clear_output

def display_board(board):
    print(board[7] + ' | ' + board[8] + ' | ' + board[9])
    print('--|---|--')
    print(board[4] + ' | ' + board[5] + ' | ' + board[6])
    print('--|---|--')
    print(board[1] + ' | ' + board[2] + ' | ' + board[3])

test_board = [' '] * 10
display_board(test_board)


def player_input():
    marker = ''


    while not (marker == 'X' or marker == 'O'):
        marker = raw_input('Player 1: Do you want to be X or O? ').upper()


    if marker == 'X':
        return ('X', 'O')
    else:
        return ('O', 'X')

player1_marker, player2_marker = player_input()

0 个答案:

没有答案