How to print the largest value from Python dictionary?

PythonServer Side ProgrammingProgramming

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
raja
Published on 27-Feb-2018 19:56:45
Advertisements