I have a matrix which is given in a list of lists:
board = [[1, 0, 0, 1], [-1, -1, 1, 1], [0, 0, 0, 0]]
What I want to do is change the board but without copying. I want to change it into a columns board:
def foo(board):
change board to columns board
board = foo(board)
This is the result:
board = [[1, -1, 0], [0, -1, 0], [0, 1, 0], [1, 1, 0]]
Problem is it creates a new variable with the same name (board) and doesn't change the original board.
I need to change the original board as I need to use it in different places afterward.
Cannot return the board, as I would've gladly done without thinking about it (not allowed).
Even tried:
a = foo(board)
board.clear()
board += a
Which should work but for some reason bugs my program. any help would be appreciated