Cody Bable

Generation

generate functionFri, 30 Jun 2023

return the two biggest numbers in a list of dictionaries

def find_biggest_numbers_in_list_of_dictionaries(my_list): biggest_number_1 = my_list[0]["number"] biggest_number_2 = my_list[1]["number"] for d in my_list: if d["number"] > biggest_number_1: biggest_number_2 = biggest_number_1 biggest_number_1 = d["number"] else: if d["number"] > biggest_number_2: biggest_number_2 = d["number"] return biggest_number_1, biggest_number_2

Questions about programming?Chat with your personal AI assistant