cost = [[-1]*2]*2
matrix = [[2,3],[4,5]]
for i in range(2):
for j in range(2):
if i == 0:
cost[i][j] = matrix[i][j]
print(cost)
I am expecting output [[2,3],[-1, -1]], but the actual output is [[2, 3],[2,3]]. I am not understanding that why are second-row elements are getting changed along with the first row?