Add Items
Assigning a new key adds a field. A dictionary is flexible, but an application record should still have a known schema or validation boundary.
Understand the idea
A new assignment appends that key to the insertion order. setdefault returns an existing value or stores a supplied default when absent. This can help accumulate groups, but its default expression is evaluated before the call even if the key already exists. Use clear code when construction has side effects or significant cost.
Where to try it
Open this example with Try in playground. The code loads as editable text and does not run until you select Run. The first run downloads Python. Each run starts fresh; temporary files created by a script are not files on your PC.
A worked example
groups = {}
groups.setdefault("Python", []).append("Mira")
groups.setdefault("Python", []).append("Dev")
print(groups)
Read the result
The Python group contains Mira and Dev in one list.
Try one change
Add a CSS group without overwriting the existing Python list.