When creating a new nested list the following way:
test_list = [[""]]*5
unexpected behavior happens, appending to an index the following modifications happens:
test_list[1].append(2)
[['', 2], ['', 2], ['', 2], ['', 2], ['', 2]]
when doing the following it works as I would expect:
test_list[1] = test_list[1] + [0]
[[''], ['', 0], [''], [''], ['']]
but when using the += operator the same odd thing happens
test_list[1] += [0]
[['', 0], ['', 0], ['', 0], ['', 0], ['', 0]]
when the list is defined as following: [[""] for i in range(len(5))]
all the examples return the expected output.
What is going on? Is it some reference thing I am not understanding?