I'm trying to do the text refresh to be able to display some information in the same line, basically rewriting the old text.
code sample:
from time import sleep
def countdown(n):
if n > 0 :
print(n)
sleep(0.3)
countdown(n-1)
else :
print("Blastoff!")
countdown(3)
If I use the "\r" in the print statement, it does \n two times.
I tried the carriage return "\r" and the cls clear() function, everything on stack, but nothing works for Mac.
code sample:
from time import sleep
def countdown(n):
if n > 0 :
print(n)
sleep(0.3)
countdown(n-1)
else :
print("Blastoff!")
countdown(6)
If I use the "\r" in the print statement, it does \n two times. this is the current output: 3 2 1 Blastoff!
in the same window.
i'd like to have the output as follows: 3 # in the first line
2 # in the same spot that 3 was.. and so on. . . Blastoff! # at the end will be the only thing on the screen.