Apologies for the rather ambiguous title, but I couldn't think of a better way to put it. In Python, I can initialize empty lists or other variables like:
>>> a, b, c = [[]] * 3
>>> d, e, f = [0] * 3
I noticed that if I initialize the empty lists like this, then they are all connected so when I do:
>>> a.append(3)
The element 3
is also appended to lists b
and c
.
What is the reason for this behavior? Also, what is this style of initialization called? Thanks.