I'm trying to do something with the python list of list but I found something weird about the indexing.
If I want to create a 2*2 "matrix", I do
matrix = [[0]*2]*2
Then if I want to change the first row first column by using, say,
matrix[0][0] = 1
I will get [[1,0],[1,0]]
, instead of [[1,0],[0,0]]
. Does anyone know what went wrong?