I didn’t actually able to come up with the best suitable title for this. But the problem is: I have this little function, which prints a count up timer on the screen:
def timer(x):
for i in range(1,x):
sys.stdout.write("\r%d" % i)
sys.stdout.flush()
sleep(1)
sys.stdout.write('\r \r')
How can I append the timer at the end of a print statement, like: Now counting.... 3? I tried this:
sys.stdout.write('Now counting..... ')
timer(6)
But it’s printing the timer in the beginning of the line, replacing first two characters. Any help greatly appreciated. Cheers!!
Why not pass your message to the
timerfunction?