Generation

generate functionWed, 21 Dec 2022

Rewrite this function without lambda max_key = max(dct, key=lambda key: dct[key]['Value'])

def max_key(dct): max_v = 0 max_k = ' ' for key in dct: if dct[key]['Value'] > max_v: max_v = dct[key]['Value'] max_k = key return max_k dct = {'a': {'Value': 1, 'Other': 2}, 'b': {'Value': 5, 'Other': 4}, 'c': {'Value': 3, 'Other': 4}} max_key(dct)

Questions about programming?Chat with your personal AI assistant