<div>Here is the code.</div>
<div>&nbsp;</div>
<div>for line in file(&#39;test.txt&#39;):<br>&nbsp;&nbsp;&nbsp; the_line = line.split()<br>&nbsp;&nbsp;&nbsp; if the_line:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if the_line[0] == &#39;Index&#39;:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; index = float(the_line[-1])<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print (&quot;\rIndex = %.3f&quot;) %index
</div>
<div>raw_input(&quot;\nExit&quot;)</div>
<div>&nbsp;</div>
<div>Here is the output.</div>
<div><br>Index = 0.000</div>
<div>Index = 0.400</div>
<div>Index = 0.800</div>
<div>Index = 1.000</div>
<div>&nbsp;</div>
<div>Exit<br><br><br></div>
<div class="gmail_quote">On Dec 10, 2007 4:33 PM, Kent Johnson &lt;<a href="mailto:kent37@tds.net">kent37@tds.net</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div class="Ih2E3d">Bryan Fodness wrote:<br>&gt; I do want to overwrite the same line.<br>&gt;<br>&gt; I do not see a difference between using the \r and not using it.<br><br></div>How are you running the program? Try it from a command line if that is
<br>not what you are doing. Can you show your new code?<br><font color="#888888"><br>Kent<br></font><br>PS Please Reply All to stay on the list.<br>
<div class="Ih2E3d"><br>&gt;<br>&gt; On Dec 10, 2007 2:43 PM, Kent Johnson &lt;<a href="mailto:kent37@tds.net">kent37@tds.net</a><br></div>
<div>
<div></div>
<div class="Wj3C7c">&gt; &lt;mailto:<a href="mailto:kent37@tds.net">kent37@tds.net</a>&gt;&gt; wrote:<br>&gt;<br>&gt; &nbsp; &nbsp; Bryan Fodness wrote:<br>&gt; &nbsp; &nbsp; &nbsp;&gt; I have a print statement in a for loop so I can watch the progress
<br>&gt; &nbsp; &nbsp; &nbsp;&gt;<br>&gt; &nbsp; &nbsp; &nbsp;&gt; for line in file(file):<br>&gt; &nbsp; &nbsp; &nbsp;&gt; &nbsp; &nbsp; the_line = line.split()<br>&gt; &nbsp; &nbsp; &nbsp;&gt; &nbsp; &nbsp; if the_line:<br>&gt; &nbsp; &nbsp; &nbsp;&gt; &nbsp; &nbsp; &nbsp; &nbsp; print (&quot;Index = %.2f&quot;) %index<br>&gt; &nbsp; &nbsp; &nbsp;&gt;
<br>&gt; &nbsp; &nbsp; &nbsp;&gt; Is there a way that only one line will be output and the variable is<br>&gt; &nbsp; &nbsp; &nbsp;&gt; updated rather than one line for every index.<br>&gt;<br>&gt; &nbsp; &nbsp; I&#39;m not sure I understand what you are asking. index is never
<br>&gt; &nbsp; &nbsp; updated in<br>&gt; &nbsp; &nbsp; the loop above.<br>&gt;<br>&gt; &nbsp; &nbsp; If you want to overwrite the same line on the console, try<br>&gt; &nbsp; &nbsp; &nbsp; print &quot;\rIndex = %.2f&quot; % index,<br>&gt;<br>&gt; &nbsp; &nbsp; note ----^<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;---------------------------^<br>&gt;<br>&gt; &nbsp; &nbsp; You might need some extra spaces at the end of the print to &#39;erase&#39; a<br>&gt; &nbsp; &nbsp; longer previous line.<br>&gt;<br>&gt; &nbsp; &nbsp; Kent<br>&gt;<br>&gt;<br>&gt;
<br>&gt;<br>&gt; --<br>&gt; &quot;The game of science can accurately be described as a never-ending<br>&gt; insult to human intelligence.&quot; - Joćo Magueijo<br><br></div></div></blockquote></div><br><br clear="all"><br>
-- <br>"The game of science can accurately be described as a never-ending insult to human intelligence." - Joćo Magueijo