所以我在这里有一个tic tac toe程序的代码
def playerID():
# asks player if want x or y
letter = ''
while not (letter == 'X' or letter == 'O'):
letter = input('Do you want to be X or O?').upper()
# first tuple is player, second is computer
if letter == 'X':
return ['X', 'O']
else:
return ['O', 'X']
代码的后半部分是
while True:
# resets the board
theBoard = [' '] * 10
playerLetter, computerLetter = playerID()
turn = playFirst()
print('The ' + turn + ' will go first.')
之后继续,但它是giving me two error's。我不认为这是区分大小写的。我对字符串或数组不是很好,有人能指出我在这里做错了吗?
我认为这是回调的问题,但当然我可以说出我的屁股。
答案 0 :(得分:3)
您应该使用raw_input
代替input
来获取python 2.x中的string
值