我正在使用 2-d Numpy 数组制作井字游戏,并希望它能够使用字典将用户输入的输入转换为正确的矩阵位置,但出现此错误:
movesDict = {1:[[0][0]], 2:[[0][1]], 3:[[0][2]], 4:[[1][0]], 5:[[1][1]], 6:[[1][2]], 7:[[2][0]], 8:[[2][1]], 9:[[2][2]]}
IndexError: list index out of range
示例用户给出数字 1 并将其转换为矩阵位置 [0][0] 并轮到他们放置在那里
move = input("Move to which place {}?".format(turn))
realMove = movesDict[move]