I create 4 identical lists of lists L1, L2, L3, L4
>>> L0 = [[1]]
>>> L1 = [[1],[1]]
>>> L2 = [[1] for i in range(2)]
>>> L3 = L0 + L0
>>> L4 = [[1]] * 2
>>> L1
[[1], [1]]
>>> L2
[[1], [1]]
>>> L3
[[1], [1]]
>>> L4
[[1], [1]]
>>> L1 == L2 == L3 == L4
True
And apply list.append() to the first element in each
>>> L1[0].append(2)
>>> L2[0].append(2)
>>> L3[0].append(2)
>>> L4[0].append(2)
with result
>>> L1
[[1, 2], [1]]
>>> L2
[[1, 2], [1]]
>>> L3
[[1, 2], [1, 2]]
>>> L4
[[1, 2], [1, 2]]
Can somebody please explain the output for L3 and L4?