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}}