So i have a list for tic tac toe and I reacive the board like this
board=[' ', 'X', 'O', ' ', ' ', 'X', ' ', 'O', ' ', ' ']
I would like to make to two variable for something in my mind
the first variable is the O_variable
wich will contain all the o's in the list and replace them with 1 and should be like this [0,0,1,0,0,0,0,1,0,0]
and the same for the x's [0,1,0,0,0,1,0,0,0,0]
so try the following code
Bo_variable=O_variable=x_variable=[0,0,0,0,0,0,0,0,0,0]
for i in range(len(board)):
if board[i]=='O':
O_variable[i]=1
if boardt[i]=='X':
x_variable[i]=1
but the outcome for both variable O_variable
and x_variable
is the same
[0,1,1,0,0,1,0,1,0,0]
what causes this? Note : I don't to encode the list from the first i receive it like this