(Sep-06-2020, 02:22 PM)DPaul Wrote: Still one down : the "between" or "range" case.it will be the same workaround like the tuple
def spam(): return 'spam' def eggs(): return 'eggs' menu = {(2, 5):spam, (8, 10):eggs} def lookup(lookup_key, menu): for (start, end), value in menu.items(): if start <= lookup_key <= end: return value print(lookup(9, menu)())Here the tricky part is handling overlapping keys
(Sep-06-2020, 02:22 PM)DPaul Wrote: a kind of tuple 'list'.no, it's not kind of tuple list, it's a tuple
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs