Python Tutorial

Python Nested Dictionary Explained WIth Examples

What is a Nested Dictionary in Python?

Nested dictionaries are dictionaries that contain other dictionaries.

Example: 

Create a dictionary that contains three dictionaries:

myfamily = {

  "child1" : {

    "name" : "Emil",

    "year" : 2004

  },

  "child2" : {

    "name" : "Tobias",

    "year" : 2007

  },

  "child3" : {

    "name" : "Linus",

    "year" : 2011

  }

}

Output:

{'child1': {'name': 'Emil', 'year': 2004}, 'child2': {'name': 'Tobias', 'year': 2007}, 'child3': {'name': 'Linus', 'year': 2011}}

Video : https://youtu.be/xD_URwm5Pug

Did you find this article helpful?