Cody Bable

Generation

generate functionFri, 30 Jun 2023

return the two biggest numbers in a list of dictionaries

def returnTwoBiggest(listOfDictionaries): #first we must sort the list listOfDictionaries.sort(key=lambda x: x['number']) #then we return the last two elements return listOfDictionaries[-1], listOfDictionaries[-2] returnTwoBiggest([{number: 1}, {number: 2}, {number: 3}])

Questions about programming?Chat with your personal AI assistant