Answers for "python get nested dictionary keys"

2

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)
# Prints {'emp1': {'name': 'Bob', 'job': 'Mgr'},
#         'emp2': {'name': 'Kim', 'job': 'Dev'},
#         'emp3': {'name': 'Sam', 'job': 'Dev'}}
Posted by: Guest on November-08-2020
0

python get nested dictionary keys

example_dict.get('key1', {}).get('key2')
Posted by: Guest on August-13-2021
0

nested dictionary python

people = {1: {'name': 'John', 'age': '27', 'sex': 'Male'},
          2: {'name': 'Marie', 'age': '22', 'sex': 'Female'}}

people[3] = {}

people[3]['name'] = 'Luna'
people[3]['age'] = '24'
people[3]['sex'] = 'Female'
people[3]['married'] = 'No'

print(people[3])

#Output:
# {'name': 'Luna', 'age': '24', 'sex': 'Female', 'married': 'No'}
Posted by: Guest on July-21-2021
0

how to get values of nested dictionary in python

people = {1: {'name': {'John': 'hey', 'man':'hello'} 'age': '27', 'sex': 'Male'},
          2: {'name': 'Marie', 'age': '22', 'sex': 'Female'}}

print(people[1]['name']['John'])
print(people[1]['age'])
print(people[1]['sex'])
Posted by: Guest on June-17-2021
0

how to get values of nested dictionary in python

John
27
Male
Posted by: Guest on June-17-2021

Code answers related to "python get nested dictionary keys"

Python Answers by Framework

Browse Popular Code Answers by Language