Q:

Python dictionary subelements to list

I have a dictionary like the following:
d = {"result": {"page": "1", "games": {"game": {"id": "2016", "name": "Exemple"}}}}

I would like to group all sub-values of d['result']['games']['game'] in a list, like:
d = {"result": {"page": "1", "games": {"game": [{"id": "2016", "name": "Exemple"}]}}}

How can I do this programmatically, modifying my dict variable?

A:

d['result']['games']['game'] = [d['result']['games']['game']]
and if you want to add another element
d['result']['games']['game'].append({some other dict})

