0

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?

0

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.