Cody Bable

Generation

generate functionFri, 30 Jun 2023

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

data = [{"a": 10}, {"a": 30}, {"a": 50}, {"a": 40}] def get_two_biggest(data): return sorted(data, key=lambda x: x["a"], reverse=True)[:2] get_two_biggest(data)

Want to kickstart your project?Use the new AI Studio to create your code