Alex Alex - 6 months ago 45
Python Question

Python - Remove and Replace Printed items

[Using Python 3.2]
I was wondering if it was possible to remove items you have printed in python, not from the python gui but from the command propt.

a = 0
for x in range (0,3):
a = a + 1
b = ("Loading" + "." * a)
print (a)

so it prints


But, My problem is I want this all on one line, and for it it remove it self when somthing else comes along. so instead of going, "loading", "loading.", "loa.... I want it to got "Loading.", then it removes what is on the line and replaces it with "Loading.." and then removes "Loading.." and replaces it (on the same line) with "Loading...". Its kinda hard to discribe.

I have tried to use the Backspace charactor but it doesnt seem to work ("\b")



Just use CR to go to beginning of the line.

import time
for x in range (0,5):  
    b = "Loading" + "." * x
    print (b, end="\r")