title: Why does the following loop keep returning me results of 0?
body: <p>So I'm trying to generate a frequency spectrum, and in order to do that I'm trying to sort my data into bins from a column, which I have appended data from, called minorallelefreq. For some reason, the code is not working because I get a value of 0 for all 5 bins. </p>
  
  <p>Here's the code: </p>
  
  <pre><code>minprop = 0
  minprop1 = 0
  minprop2 = 0
  minprop3 = 0
  minprop4 = 0 
  
  for x in range(1,100):
  
      if minorallelefreq[x] &lt;= 0.1:
          minprop = minprop + 1 
      if minorallelefreq[x] &gt; 0.1 and minorallelefreq[x] &lt;= 0.2: 
          minprop1 = minprop1 + 1 
      if minorallelefreq[x] &gt; 0.2 and minorallelefreq[x] &lt;= 0.3: 
          minprop2 = minprop2 + 1
      if minorallelefreq[x] &gt; 0.3 and minorallelefreq[x] &lt;= 0.4: 
          minprop3 = minprop3 + 1
      if minorallelefreq[x] &gt; 0.4 and minorallelefreq[x] &lt;= 0.5:
          minprop4 = minprop4 + 1
  
  
  
  bin1 = minprop/float(counter)
  bin2 = minprop1/float(counter)
  bin3 = minprop2/float(counter)
  bin4 = minprop3/float(counter)
  bin5 = minprop4/float(counter)  
  print "Bin1 (0-0.1)=", bin1, "\t", "Bin2 (0.1-0.2)=", bin2, "\t", "Bin3 (0.2-0.3)=", bin3, "\t", "Bin4 (0.3-0.4)=", bin4, "\t", "Bin5 (0.4-0.5)=", bin5
  </code></pre>
  
  <p><strong>So it turned out that the reason the loops weren't working is because python wasn't reading my values (which are all decimals) as decimals. So, I had to change it to float(minorallelefreq[x]), and it worked.</strong> </p>