>>> f = [[]] * 3
[[], [], []]
>>> f[0].append(1)
[[1], [1], [1]]
I think [[]] * x
creates a list of x
lists, but each inner list is the same object so changing one inner list changes all the others.
How can I quickly initialise a list of lists, but have each inner list be unique?
I want
>>> f = something
[[], [], []]
>>> f[0].append(1)
[[1], [], []]