python: while loop does not reach last iteration
<p>I don't get the result of this code:</p>

<pre><code>a = i = 0.05
b = 1.0
while a &lt;= b:
  print a
  a += i
</code></pre>

<p>Of course this should print 0.05,0.1,...,1.0 but instead the iteration stops at 0.95. Is it a float issue?</p>

<p>Yes, you're working with floating point numbers, so you won't end up exactly at 1.0. Set b to e.g. 1.001 to cater for the rounding errors. Note that your numbers will be represented in binary. If they were truly decimal, they could be represented exactly.</p>

<p>By the way, I'd rather use:</p>

<pre><code>for i in range (1, 21):
    print i/20.
</code></pre>

<p>Note that the . (or .0) behind the 20 makes it a float, forcing float division.</p>

python while-loop iteration