I have a function that looks like this https://i.stack.imgur.com/PQTjc.png I assign the variable test to board[:] (board is an 8x8 list of lists). Later in the function I make a change to test, and send test to another function. The problem is: when test gets changed, the same change happens to board. Any tips to solve this?
code:
def move(piece, loc):
global board
test = board[:]
global count
global turn
loc0 = location(piece)
if count % 2 == 0:
turn = "w"
else:
turn = "b"
if piece:
if legal(piece, loc):
test[loc0[0]][loc0[1]] = ""
test[loc[0]][loc[1]] = piece
print(test[5],board[5])
if check(test) == False:
board = test[:]
count += 1
paint(board)
print(test[5],board[5])
I tried to use assign test to board[:] to store it in a diffrent place or something, but it still didn't work.