title: Why does Progress Bar always stuck at 99%?
body: <p>I have written a small program for a Progress bar in python. But this program always stuck at 99%. There is always an inaccuracy of 1%. Below is my code.</p>
  
  <pre><code>import time
  import sys
  
  for i in range(100):
      time.sleep(1)
      sys.stdout.write("\r%d%%" % i)
      percent = float(i)/100
      hashes = '#' * int(percent * 50)
      spaces = '-' * (50 - len(hashes))
      sys.stdout.write("\rPercent: [{0}] {1}%".format(hashes + spaces, int(percent * 100)))
      sys.stdout.flush()
  </code></pre>
  
  <p>In the above program there is always an inaccuracy of 1%. If i take range as 100 and then calculate %; my progress bar stuck at 99% and if the range is 50 my progress bar stuck at 98%. can anyone please tell me if a am doing something wrong here ?</p>