return list dictionary of the two biggest numbers in a list of dictionaries
def get_top_numbers(numbers): if len(numbers) == 0: return [] biggest_num = numbers[0]['number'] second_biggest_num = numbers[0]['number'] biggest_num_dict = numbers[0] second_biggest_num_dict = numbers[0] for i in range(1, len(numbers)): if biggest_num < numbers[i]['number']: second_biggest_num = biggest_num second_biggest_num_dict = biggest_num_dict biggest_num = numbers[i]['number'] biggest_num_dict = numbers[i] elif second_biggest_num < numbers[i]['number']: second_biggest_num = numbers[i]['number'] second_biggest_num_dict = numbers[i] return [biggest_num_dict, second_biggest_num_dict]