Regarding the code below:
A = [[1, 2], [3, 4]]
A[0] = A[1]
B = A[:][0]
B[0] = 5
print(A)
print(B)
I'm wondering why printing B
gives [5, 4]
.
I thought that B = A[:][0]
is the same as A[0][0]
, A[1][0]
, which would then be [3, 3]
. Then, B[0] = 5
, so it would print [5, 3]
.
Could someone kindly clear up my confusion?