-1

i tried calling .copy on it and then passing it in the function. that didn't work. when i tried coppying in the function itself it still changed the original list. the function is in another file

main.py

win_condition.check_r_win(board)

win_condition.py

def check_r_win(board):
    board = _board.copy()
    for col in board:
        while(len(col) <= ROWS):
            col.append("-")
Rik Smits
  • 31
  • 7
  • Presumably board is a list *of mutable objects* (more lists?) and you're only doing a *shallow* copy. – jonrsharpe Nov 04 '20 at 20:28
  • Does this answer your question? [Python copy a list of lists](https://stackoverflow.com/questions/28684154/python-copy-a-list-of-lists) – jonrsharpe Nov 04 '20 at 20:29

1 Answers1

0

I don't really get what you are trying here. Python's list is a mutable object type. If you pass a object reference of a list to a function and change the list within this function, it also gets changed outside of the function scope.

Tom Gebel
  • 744
  • 1
  • 4
  • 13