I have a 2 dimensinal dictionary representing people. Here’s an example of it:
>>> people = {'pk1':{'firstname':'Brian', 'age':42}, 'pk2':{'firstname':'Alex',
'age':50}}
As can be seen, there is a primary key in each entry. Each one then points to a dictionary containing information about a specific person. How do I search the overall ‘people’ dictionary to return me all people who have the age 42?
If you want to use a more generic function that can perform various searches you can use something like:
Then for age == 42 you can call it like: