I was trying to initialize a matrix in Python. I did this:
matrix = [[0] * 9] * 9
matrix[0][0] = 1
print(matrix[1][0])
This outputs 1.
Can someone explain why this happens and how [[0] * 9] * 9 works.
My guess is that all the vectors are pointers to the same vector instead of to different vectors, but I don't know why that happens and why [0] * 9 doesn't have the same issue.