Cody Bable

Generation

generate functionFri, 30 Jun 2023

return list dictionary of the two biggest numbers in a list of dictionaries

def two_biggest(lst): lst = sorted(lst, key=lambda x: x['value'], reverse=True) return lst[:2] lst = [{'value': 1}, {'value': 2}, {'value': 3}] two_biggest(lst)

Questions about programming?Chat with your personal AI assistant