I have a list with empty dictionaries. If I update one element of the list, I see same changes in all other elements as well.
my_list = [{}] * 5
print(my_list)
my_list[0]["name"] = "john"
print(my_list)
Outputs:
[{}, {}, {}, {}, {}]
[{'name': 'john'}, {'name': 'john'}, {'name': 'john'}, {'name': 'john'}, {'name': 'john'}]
I expected an output like this:
[{}, {}, {}, {}, {}]
[{'name': 'john'}, {}, {}, {}, {}]
Any suggestions will be appreciated.