How to reset cursor to the beginning of the same line in Python
<p>Most of questions related to this topics here in SO is as follows:</p>

<blockquote>
  <p>How to print some information on the same line without introducing a
  new line</p>
</blockquote>

<p><a href="http://stackoverflow.com/questions/3249524">Q1</a> <a href="http://stackoverflow.com/questions/493386">Q2</a>.</p>

<p>Instead, my question is as follows:</p>

<p>I expect to see the following effect,</p>

<pre><code>&gt;&gt; You have finished 10%
</code></pre>

<p>where the <code>10</code> keep increasing in the same time. I know how to do this in C++ but cannot
find a good solution in python.</p>

<p>// ================== Updated ==============================================
Based on the helps from aix and petr, here is the solution to this question:</p>

<pre><code># for Python 3
for i in range(0, 101, 10):
  print('\r&gt;&gt; You have finished %d%%' % i, end='\r')
  sys.stdout.flush()
  time.sleep(1)
print

# for Python 2
for i in xrange(0, 101, 10): # for p2
  print '\r&gt;&gt; You have finished %d%%' % i,
  sys.stdout.flush()
  time.sleep(1)
print
</code></pre>
