Consider the following code:
a = [[]] * 3a[1].append("foo")
I would expect the value of a
to become:
[[], ["foo"], []]
instead, every element of a
is updated:
[["foo"], ["foo"], ["foo"]]
Why?
Consider the following code:
a = [[]] * 3a[1].append("foo")
I would expect the value of a
to become:
[[], ["foo"], []]
instead, every element of a
is updated:
[["foo"], ["foo"], ["foo"]]
Why?