I'm having trouble to add a dictionary in a list of dictionary. Here is my problem description:
>> my_list = [{}]*4
>> my_list
[{}, {}, {}, {}]
>> my_list[0]
{}
>> key=(0,0,0,0)
>> my_list[0][key]=[]
>> my_list[0]
{(0, 0, 0, 0): []}
So far so good, but if I print my_list, this is not what I expected:
>> my_list
[{(0, 0, 0, 0): []}, {(0, 0, 0, 0): []}, {(0, 0, 0, 0): []}, {(0, 0, 0, 0): []}]
What I expected is:
[{(0, 0, 0, 0): []}, {}, {}, {}]
What is going on? I only add one entry into the first element of my_list. I don't expect my_list[1:3] have the same thing.
Please help!! Many thanks, Richard