title: Putting floating point ranges into bins
body: <p>Given 5 ranges </p>
  
  <pre><code>[(0., 0.), (0., 0.3), (0.3, 0.5), (0.5, 0.8), (0.8, 1.0)]
  </code></pre>
  
  <p>that corresponds to:</p>
  
  <ul>
  <li>[0.0, 0.0]</li>
  <li>(0.0, 0.3]</li>
  <li>(0.3, 0.5]</li>
  <li>(0.5, 0.8]</li>
  <li>(0.8, 1.0]</li>
  </ul>
  
  <p>And a list of input floats:</p>
  
  <pre><code>[0.5293113408538,
   0.3105914215541,
   0.7748290363338001,
   0.7745464933980998,
   0.17276995816109997,
   0.83335888200110002,
   0.0]
  </code></pre>
  
  <p>The goal is to bin the floats into the ranges above and output:</p>
  
  <pre><code>[3, 2, 3, 3, 1, 4, 0]
  </code></pre>
  
  <p>I have tried this:</p>
  
  <pre><code>score_ranges =  [(0., 0.), (0., 0.3), (0.3, 0.5), (0.5, 0.8), (0.8, 1.0)]
  
  x = [0.5293113408538,
   0.3105914215541,
   0.7748290363338001,
   0.7745464933980998,
   0.17276995816109997,
   0.83335888200110002,
   0.0]
  
  binning = []
  
  for i in x:
      for j, (start, end) in enumerate(score_ranges):
          if i == 0:
              binning.append(0)
              break
          elif start &lt; i &lt;= end:
              binning.append(j)
              break
  </code></pre>
  
  <p><strong>But is there a less verbose way to get the desired bining outputs?</strong></p>
  
  <p><strong>Additionally, the zero range is sort of hard coded there because its lower bound is inclusive unlike the other classes, is there a better way to handle that?</strong></p>