programming-examples/python/Dictionary/Python program to get the maximum and minimum value in a dictionary.py
2019-11-15 12:59:38 +01:00

7 lines
260 B
Python

my_dict = {'x':500, 'y':5874, 'z': 560}
key_max = max(my_dict.keys(), key=(lambda k: my_dict[k]))
key_min = min(my_dict.keys(), key=(lambda k: my_dict[k]))
print('Maximum Value: ',my_dict[key_max])
print('Minimum Value: ',my_dict[key_min])