Cody Bable

Generation

generate functionFri, 30 Jun 2023

return the two biggest numbers in a list of dictionaries

data = [ {'age': 43, 'name': 'Alice'}, {'age': 53, 'name': 'Bob'}, ] def biggest(data): return sorted(data, key=lambda x: x['age'], reverse=True)[:2] biggest(data)

Questions about programming?Chat with your personal AI assistant