Computer >> Computer tutorials >  >> Programming >> Python

How to print the largest value from Python dictionary?


Python's built-in dictionary class has values() method which returns list of value component from each key-value pair. Using built-in function max() the largest value in the dictionary can be obtained

>>> dct={1:45,2:76,3:12,4:55,5:33}
>>> vlist=dct.values()
>>> vlist
dict_values([45, 76, 12, 55, 33])
>>> max(vlist)
76