title: Python: splitting dictionary into smaller dictionaries by keys (tuple)
body: <p>I have a dictionary where keys are tuples of two integers <code>(x,y)</code> and values are strings. </p>
  
  <p>How do I split this dictionary up into smaller dictionaries, where the split is determined by whether the <code>y</code>-value is greater than some treshold?</p>
  
  <p>For example, say I have the keys (the dictionary values are irrelevant so I omit them here)</p>
  
  <p><code>(0, 2), (0, 4), (0, 10), (0, 3), (0, 11), (0, 20), (0, 8), (0, 14)</code></p>
  
  <p>and say I have the tresholds <code>0, 5, 10, 15</code>. </p>
  
  <p>Then, one split should consist of a dictionary with the following keys:</p>
  
  <p><code>(0,2), (0,4), (0,3)</code></p>
  
  <p>since the y-values are all greater than 0, but not greater than 5. </p>
  
  <p>Then the next dictionary should have keys</p>
  
  <p><code>(0,8)</code></p>
  
  <p>since it is greater than 0 and 5, but not greater than 10.</p>
  
  <p>Then we have <code>(0, 10), (0, 11), (0, 14)</code></p>
  
  <p>since it is greater (or equal to) 0, 5, 10, but not 15.</p>
  
  <p>Finally, we have <code>(0, 20)</code> by itself. </p>