I would like to append to a single list within a list, without appending to all the 'sibling' lists at the same time.
Suppose I have an empty list of empty lists in Python, such as the following:
from math import pi
test = [[]] * 3
test
Out[88]: [[], [], []]
Now suppose I want to append an element only to the first nested list. I would say that selecting the first list, index 0:
test[0]
Out[89]: []
and appending to that list as follows:
test[0].append(pi)
should yield a list that looks as follows:
[[3.141592653589793], [], []]
However, when printing the result, I get the following:
test
Out[91]: [[3.141592653589793], [3.141592653589793], [3.141592653589793]]
Can anyone point out where I am making my mistake?
Thanks in advance.