IM接收"list assignment index out of range"
列表分配索引超出範圍(創建掃雷艇板)
def createBoard(rows, cols, mines):
board = []
for n_row in range(rows):
board.append([])
for n_col in range(cols):
board.append([])
# Place a random letter at each location in the board
for n_row in range(rows):
for n_col in range(cols):
board[n_row][n_col] = ("C")
我建議你在第二部分前打印'board'。這不是你想象的那樣。 – TigerhawkT3