[0] * size_of_array creates a list that contains several references to 0 . If you put a different value on this list, it will not be affected.
As you noticed, [[]] * num creates a list that contains a link to the same list again and again. Change this list, the change is visible on all links.
>>> a = [0] * 10 >>> [id(i) for i in a] [31351584L, 31351584L, 31351584L, 31351584L, 31351584L, 31351584L, 31351584L, 31351584L, 31351584L, 31351584L] >>> >>> all(i is a[0] for i in a) True
vs.
>>> a = [[]] * 10 >>> a [[], [], [], [], [], [], [], [], [], []] >>> [id(i) for i in a] [44072200L, 44072200L, 44072200L, 44072200L, 44072200L, 44072200L, 44072200L, 44072200L, 44072200L, 44072200L] >>> all(i is a[0] for i in a) True
In the same situation, but one thing is different:
If you execute a[0].append(10) , the effect is displayed in all lists.
But if you do a.append([]) , you add a clean new list that is not related to others:
>>> a = [[]] * 10 >>> a [[], [], [], [], [], [], [], [], [], []] >>> a.append([]) >>> a[0].append(8) >>> a [[8], [8], [8], [8], [8], [8], [8], [8], [8], [8], []] >>> a[-1].append(5) >>> a [[8], [8], [8], [8], [8], [8], [8], [8], [8], [8], [5]]