Cody Bable

Generation

generate functionFri, 30 Jun 2023

return the two biggest numbers in a list of dictionaries

def twoBiggest(l): return sorted(l, key=lambda d: d['key'])[-2:] l = [{'key': 2}, {'key': 1}, {'key': 3}] twoBiggest(l)

Questions about programming?Chat with your personal AI assistant