我正在尝试创建一个tic tac toe游戏,基于Al Sweigart的Invent Your Own Computer Games with Python book。在设置电路板列表时,我发现它不会打印;这是我的代码:
board = ['', 'X', '', '', '', 'O', 'O', '', '', '']
# The board is a list of 10 strings, representing the board
print(' | |')
print(' ' + board[7] + ' | ' + board[8] + ' | ' + board[9])
print(' | |')
print('----------')
print(' ' + board[4] + ' | ' + board[5] + ' | ' + board[6])
print(' | |')
print('----------')
print(' ' + board[1] + ' | ' + board[2] + ' | ' + board[3])
print(' | |')
当我运行它时,控制台上根本没有显示任何内容;我没有任何错误,只是一个空白的屏幕。如果有人能提供任何帮助,我将不胜感激。谢谢。