I have a 2D array that I need to constantly update and assign to different variables but the update has to take place from the initial array. Since lists are passed by reference and not by value the regular assignment does not work. I tried: list1 = list2[:] which works perfectly fine with a 1D arrays but not with a 2D array.
Has anyone encountered this before?
list
objects and not either of the typical array objects in python. In any case, it sounds like what you need is to simply copy or perhaps deep copy your lists at some point, but you need to provide an actual minimal reproducible example of the problems you are encountering, this is a classic example of the X-Y problem.