Given this nested dictionary, how could I print all the \"phone\" values using a for loop?
people = { \'Alice\': { \'phone\': \'2341\', \
Using a list comprehension
>>> [people[i]['phone'] for i in people] ['9102', '2341', '4563']
Or if you'd like to use a for loop.
for
l = [] for person in people: l.append(people[person]['phone']) >>> l ['9102', '2341', '4563']