Suppose if I have the following list of dictionaries:
heroes = [
{'id':'001', 'actor_name':'Chris Evans', 'hero_name':'Captain America'},
{'id':'002', 'actor_name':'Chris Hemsworth', 'hero_name':'Thor'},
{'id':'003', 'actor_name':'Robert Downey', 'hero_name':'Iron Man'},
{'id':'004', 'actor_name':'Don Cheadle', 'hero_name':'War Machine'},
{'id':'005', 'actor_name':'Jeremy Renner', 'hero_name':'Hawkeye'},
]
I need to get values of the form;
"Get hero id where actor name is 'Don Cheadle' and hero name is 'War Machine'
or
"Get hero name where id is 1"
How can I achieve this in python ?
Since there are multiple dictionaries in a list, there can be some dictionaries which have the same id as well. So for that case I need all such values.
This question has got me extremely confused. How can I achieve this?