I have a list currentCell
which contains info like coordinates and values and stuff. I then create a copy of that list using currentCellNew = currentCell.copy()
. Im told that doing that and modifying the copy will NOT effect the original. But when i remove something from the copy, it also removes it from the original list.
Here is the code that removes from the copy:
#some variables exist outside of scope
currentCell = next(x for x in self.cells if x[0] == currentCellCoords)
currentCellNew = currentCell.copy()
if currentCellNew[3] == 0:
if **condition**:
wallAxis = next(x[0] for x in list(self.Orientations.items()) if x[1] == "f")
#### Here is the code that removes the element from the copy #####
currentCellNew[2].remove(next(x for x in currentCellNew[2] if x[0] == wallAxis))