Python Python Collections (2016, retired 2019) Dictionaries Dictionary Basics

How do I add another dict in a dictionary ?

I need to add a key in a dictionary which's value is another dictionary which's dictionary takes another key and value . I guess my explanantion wasn't clear but ...

dicts.py
player = {"name" : "Diyan", "remaining_lives" : 3, "levels" : 1, 2, 3, 4, "items" : dict("bank" : "money")}

1 Answer

Steven Parker
Steven Parker
171,327 Points

You're close, but you have these issues:

  • the list must be enclosed in brackets :point_right: "levels" : [1, 2, 3, 4]
  • the argument to "dict" must be keyword=value :point_right: "items" : dict(bank="money")
  • -OR-   you could just use another literal :point_right: "items" : {"bank" : "money"}