Consider this example:
>>> result = [[]] * 8
>>> result
[[], [], [], [], [], [], [], []]
>>> result[0]
[]
>>> result[0].append("foo")
>>> result # wtf? expected result: [['foo'], [], [], [], [], [], [], []]
[['foo'], ['foo'], ['foo'], ['foo'], ['foo'], ['foo'], ['foo'], ['foo']]
I'm terribly confused by this. Maybe I don't understand how append
is expected to be used. How would I append to the i
th nested listed inside a list?