The question is actually pretty simply, just look at the code:
In [1]: collection = [[]] * 4
In [2]: collection
Out[2]: [[], [], [], []]
In [3]: collection[0].append(1)
In [4]: collection
Out[4]: [[1], [1], [1], [1]]
Why append 1
to collection[0]
also append it to all the other dimensions?
If that's not the correct way to add element into a specific dimension, then what's the right way?