When I execute the following commands, I expect to get a 3x3 matrix (list of lists) where all cells are zero and the central cell is a one. Instead, I get a matrix where the [0][1], [1][1], and [2][1] positions are all one:
a = [[0]*3]*3
a[1][1] = 1
This seems to suggest that all of the cells in the matrix are pointing to the same object, which is confirmed by the fact that a[0] is a[1]
returns "True". Indeed, a[0][0] is a[0][1]
also returns "True" if performed before the second expression above. So, why aren't a[0][0], a[0][2], etc (the cells in the first and third "columns") also being updated with the new value?