I am trying to find the most positive and most negative values in the dictionary imdb_dict:
imdb_dict = {'the': '0.0490972013402',
'and': '0.201363575849',
'a': '0.0333946807184',
'of': '0.099837669572',
'to': '-0.0790210365788',
'is': '0.188660139871',
'it': '0.00712569582356',
'in': '0.109215821589',
'i': '-0.154986397986'}
Using the code found here: Getting key with maximum value in dictionary?
I can obtain the maximum value of the dictionary using:
import operator
max(imdb_dict.items(), key=operator.itemgetter(1))
However, I cannot find a way to get the most negative value in the dictionary as using min shows the value closest to 0. Is there a way to modify the operator to get the maximum negative value or an easier way to accomplish the same?