python uses references when you assign it, which means
y = x
gives the values of x
another name but behind the scenes both variables point to the same values.
On the other hand when you execute
y = list(x)
a new list with a copy of the values is being created at this point.
As a special case there is a list inside the list. This is handled in exactly the same way: in the copy only the reference to the list is copied and not the list itself. Which means that the [15]
resp. [18]
is the same list which can be access on two different ways (aka x[4]
and y[4]
).
If you want that a copy is created at all levels you need to use deepcopy
like:
import copy
y = copy.deepcopy(x)