Answers for "how to get values of nested dictionary in python"

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

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
0

extract specific key values from nested dictionary

>>> [val.get('phone') for val in people.values()]
['4563', '9102', '2341']
Posted by: Guest on March-06-2021

Code answers related to "how to get values of nested dictionary in python"

Python Answers by Framework

Browse Popular Code Answers by Language