I\'m refactoring a function that, given a series of endpoints that implicitly define intervals, checks if a number is included in the interval, and then return a correspondi
d = {(None,100): 0,
(100,200): 1,
...
(1000, None): 5}
value = 300 # example value
for k,v in d.items():
if (k[0] is None or value > k[0]) and (k[1] is None or value <= k[1]):
return v