Similar to this Get Key by value question but this time, the value is inside an array. The solution i think of is loop each item the Dictionary, and loop again for each items in the value pair. But from the looks of it, this is intensive. Is this the only way?
# a dictionary that contains ranges. this dictionary might have 1million keys and the range can have many values too
dictionary = {
"x": range(0,10),
"y": range(11,20),
"z": range(21,30)
.
.
.
}
get_dictionary_value = 16
for k,v in dictionary.items():
for item in v:
if get_dictionary_value = item:
print("the key is {}".format(k)) #the output will be "the key is y"