While trying to append values to a nested list through a for loop, I came across an issue that the appending values to the list depends on the way the list is initialized.Suppose, I initialize a nested array as:
a=[[[],[],[],[]],[[],[],[],[],[]]]
a[0][1].append(2)
results in
[[[], [2], [], []], [[], [], [], [], []]]
but initializing and appending data in the following manner
a= [[[]]*4]*2
a[0][1].append(2)
results in
[[[2], [2], [2], [2]], [[2], [2], [2], [2]]]
What is the difference between the two as both of them initialize the same type of list?