Background
Consider the following code:
list_of_lists = [[]] * 5
list_of_lists[2].append(123)
print(list_of_lists)
I would expect the result to be
[[], [], [123], [], []]
But instead the result is
[[123], [123], [123], [123], [123]]
Clearly, the [[]] * 5
creates a list of 5 of the same object, so any reference to one of them, is a reference to all of them.
Question
How do I circumvent this? Can I append something to one of the lists in a list?