I notice this interesting thing in python:
>>> B = [[]*5 for _ in range(5)]
>>> B
[[], [], [], [], []]
>>> B[0].append(1)
>>> B
[[1], [], [], [], []]
>>>
Then I do this:
>>> B = [[]]*5
>>> B
[[], [], [], [], []]
>>> B[0].append(1)
>>> B
[[1], [1], [1], [1], [1]]
>>>
It seems B = [[]]*5
and B = [[]*5 for _ in range(5)]
generate the same empty list B but why they behave different when using append? Thank you for anyone who cares to explain!