How to Create Dictionary That Contains Many Dictionaries in Python


In this example we will show how to create a dictionary that contains many dictionaries in Python.

Source Code

student = {
    'student1' : {
        'name' : 'Jim',
        'id' : 12
    },
    'student2' : {
        'name' : 'Steven',
        'id' : 15
    },
    'student3' : {
        'name' : 'Lucy',
        'id' : 18
    }
}

print(student)

Output:

{'student1': {'name': 'Jim', 'id': 12}, 'student2': {'name': 'Steven', 'id': 15}, 'student3': {'name': 'Lucy', 'id': 18}}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments