title: Is there a way to have a dictionary key be a range?
body: <p>Forgive me if this is obvious, but I'm very, very new to Python.  I've found ways to get multiple keys from a dictionary, but that's not what I'm trying to do.</p>
  
  <p>Basically I'm looking for something like this:</p>
  
  <pre><code>my_dict = { "1-10" : "foo",
              "11-20" : "bar",
              # ...
              "91-100" : "baz" }
  </code></pre>
  
  <p>... but where the keys aren't actually strings and any number in that given range maps to the value.  So for example, <code>my_dict[9]</code> ought to return <code>foo</code>, just as <code>my_dict[3]</code> should.  I thought of using an explicit array, like the following, but it didn't work:</p>
  
  <pre><code>my_dict = { [1, 2, 3, ..., 10] : "foo",
  </code></pre>
  
  <p>I'm unsure if this is even a valid use-case for a dictionary, or if there is another data structure I should be using.  But Python has a way of always surprising me.  So does anyone know Python magic to make this work?</p>