I have the dict which consists of lists as values. List is len(2) representing the range of an array:
new_dict = {0: [0, 7], 1:[15, 21], 2:[-5, 3]}
I need to find the key with list that has the largest range i.e. largest list[1] - list[0]
I've done it this way and it works fine, but I am assuming it can be done in simpler, or more pythonic way.
largest = float("-inf")
largest_list = []
for key in new_dict.keys():
temp = new_dict[key][1] - new_dict[key][0]
if temp > largest:
largest = temp
largest_list = new_dict[key]