Given list of dictionaries I need to find one element of list (dictionary) with maximum field value:
people = [ {'name': 'Alice', 'age': 25}, {'name': 'Bob', 'age': 30}, {'name': 'Charlie', 'age': 22} ] # Find the dictionary with the maximum 'age' oldest_person = max(people, key=lambda person: person['age']) print(oldest_person)
Output:
{'name': 'Bob', 'age': 30}