If I build a nested list:
nested_list = 3*[[]]
and if I then add elements to it
nested_list[1] += [1, 2, 3]
. returns:[[1, 2, 3], [1, 2, 3], [1, 2, 3]]nested_list[1] = nested_list[1] + [1, 2, 3]
. returns: [[ ], [1, 2, 3], [ ]]
I would have expected to obtain the result of case 2 for both operations.
Why do I obtain a different result in case 1? Is this a design choice of python? What is the logic of the result in case 1?