How can I clear/save the current line in Python? I have a double loop that I would like to print the results of the inner loop on-line and save and show the final result of this loop after it goes to the outer loop each time. I have:
import os
for j in xrange(1,final_step_j):
Result=0
for k in xrange(1,final_step_k):
Result=Result+ j*k
os.system('clear')
print "current Result for j=%s and k=%s is %s" %(j, k, Result)
Which os.system('clear')
clearly clear the whole page every time it runs the inner loop. I want to save and show the final result of the inner loop each time and go to a new line for showing the result of the next round while the previous last line is still visible on the screen.