dictionary of dictionary in python code example
Example 1: Nested dictionary Python
IDs = ['emp1','emp2','emp3']
EmpInfo = [{'name': 'Bob', 'job': 'Mgr'},
{'name': 'Kim', 'job': 'Dev'},
{'name': 'Sam', 'job': 'Dev'}]
D = dict(zip(IDs, EmpInfo))
print(D)
Example 2: dict of dict python
nested_dict = { 'dictA': {'key_1': 'value_1'},
'dictB': {'key_2': 'value_2'}}
Example 3: python dictionary of dict
people = {1: {'name': 'John', 'age': '27', 'sex': 'Male'},
2: {'name': 'Marie', 'age': '22', 'sex': 'Female'}}
print(people[1]['name'])
print(people[1]['age'])
print(people[1]['sex'])
Example 4: python create nested dictionary
people = {1: {'name': 'John', 'age': '27', 'sex': 'Male'},
2: {'name': 'Marie', 'age': '22', 'sex': 'Female'}}
print(people)