0

I am looking for a method so that when something is printed continuously, it overwrite what the previous printed statement says. for example, if I am making a counter, normally the outcome in the IDLE would be: 1 2 3 4...., but however I'm looking to rewrite/overwrite what the previous printed statement says so it say "1" for a second then "2" appears but we can no longer see "1". Any suggestions? Sorry about how wordy this question is, I was having a hard time trying to write this where another person understands.

1 Answers1

1
import time

arr = [1,2,3,4]
for element in arr:
    print(element, end='\r')
    time.sleep(1)

end='\r' in the print statement does the trick