Zachary Ware added the comment:
See
https://docs.python.org/3/faq/programming.html#how-do-i-create-a-multidimensional-list
Not quite the same example, but the underlying reason for what you're seeing is
the same: each of the `dict` objects in `[{}] * 4` is actually the *same* dict
object:
New submission from Xin Sheng Zhou :
>>> details = [{}]*4
>>> details
[{}, {}, {}, {}]
>>> details[1]['A']=5
>>> details
[{'A': 5}, {'A': 5}, {'A': 5}, {'A': 5}]
>>>
--
messages: 403679
nosy: xinshengzhou
priority: normal
severity: normal
status: open
title: Assignment to a list of dict