I asked a question about initializing a 2 dimensional array yesterday, this is the link: How to implement this C++ source in python?
There is a problem in the answer, a friend mentioned a way:
G = [[0]*11]*11
But in this way, when I change the G[0][0] to 2, all the G[i][0](0<=i<11) will all change to 2, but I don't know why?
Supplement:
This is what I thought:
The 0 or other number is immutable, so we change one of them, the others will not be changed.
But the list [0, 0 ,0 ,.....] is mutable, so when we [0, 0, ...] * 11, all the [0, 0, ...] list will be the same, as is function is True. am I right?