I tried modifying the array "newTab" but without use tab.copy() but it always modifies the original array.
tab = [[1]*2]*3
newTab = [None] * len(tab)
for i in range(0, len(tab)):
newTab[i] = tab[i]
newTab[0][0] = 2
print(tab)
[[2, 1], [2, 1], [2, 1]]
print(newTab)
[[2, 1], [2, 1], [2, 1]]
I also tried using something like this :
a = b[:]
but it doesn't work.
Somehow the original array is always a reference to the new one.
I just started learning python and we can only use the basics for our homework. So i'm not allowed to use things like deepcopy()
Any help would be appreciated!