Are you confusing the one-line index with the element (list) one-line.
In your loop:
for row in board:
for column in row:
if p_move == board[row][column]:
board
is a list of lists, so when iterating on it, each element (row
) will be a list.
When writing board[row]
, you effectively write (for the first iteration) board[[['1','2','3']]
, causing the error you see.
A simple way to fix this is to use range
and len
, and then iterate on a numerical sequence:
board=[['1','2','3'],
['4','5','6'],
['7','8','9']]
n_rows = len(board)
n_cols = len(board[0]) # assumimos que board é quadrada
p_move = input('Enter your move: ')
for row in range(n_rows):
for column in range(n_cols):
if p_move == board[row][column]:
board[row][column] = 'O'
Thanks I was trying earlier to wear something like this
python

for row in len(board):
 for column in len(row):
– rxpha