def max_n_min(dic):
dic_list = dic.items()[0]
max = min = dic_list
for value in dic.values():
if value > max:
max = value
if value < min:
min = value
return(max, min)
<ipython-input-16-5837f0a5d1aa> in max_n_min(dic)
1 #Sums births for a requested periods
2 def max_n_min(dic):
----> 3 dic_list = dic.values()[0]
4 max = min = dic_list
5 for value in dic.values()
TypeError: 'dict_values' object does not support indexing
I'm making a function that takes the values of the keys in a dictionary as input, and outputs the max and min of those values. All values and keys are integers. I want to set the default max and min as the value of the first key, but for some reason it's giving me the above TypeError. This is strange to me because in this thread, it seems to be the recommended solution.