extract specific key values from nested dictionary code example
Example 1: extract specific key values from nested dictionary
>>> [people[i]['phone'] for i in people]
['9102', '2341', '4563']
Example 2: extract specific key values from nested dictionary
l = []
for person in people:
l.append(people[person]['phone'])
>>> l
['9102', '2341', '4563']
Example 3: extract specific key values from nested dictionary
>>> [val.get('phone') for val in people.values()]
['4563', '9102', '2341']