Cody Bable

Generation

generate functionFri, 30 Jun 2023

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

def top_three(lst: List[Dict[str, int]], sort_key: str) -> Dict[str, int]: """Return the three largest items in a list of dictionaries as a list of dictionaries. Arguments: lst -- list of dictionaries sort_key -- key to sort dictionaries by Return: sorted_lst -- sorted list of dictionaries """ # your code here sorted_lst = sorted(lst, key=lambda x: x[sort_key], reverse=True) return sorted_lst[:3]

Questions about programming?Chat with your personal AI assistant