I want to take a value from a 2D array (so this value has a type of array) and assign it to a new variable. But when I make changes to this new variable, its original value in that 2D array also changes. I want to know if there is a correct way that I can do this?
Here is my example code.
a = [[1],[2],[3]]
b = a[1]
b.append(2)
a.append(b)
print(a)
print(b)
In the output, a, b will be
a = [[1], [2, 2], [3], [2, 2]]
b = [2, 2]
Where I don't want a[1] to be changed as well. If someone can help me figure this out? Thanks.