Reputation: 580
I'm making some sort of timer. I have this code:
for i in range (19, -1, -1):
print i
time.sleep(60)
This should print value of i every minute for 20 minutes. It does it, but each output is in the new line. If I add comma after i my program firstly waits for 20 minutes to pass and then gives me output on the same line but all at once. How to make it to give me output on the same line, but to remain minute-by-minute functionality?
Upvotes: 0
Views: 386
Reputation: 72231
Sounds like your output buffer is flushed only after you print a whole line.
You can add a sys.stdout.flush()
after the print to make sure it ends up on screen immediately
Upvotes: 1