0

How would you make a loop that would keep counting up until lets say 60. And also how could you display it and then update the number on the same line?

RichardT
  • 3
  • 1
  • 1
    A loop that stops counting when a certain number is reached is not "infinite". Try something like `for i in range(60)`. – benvc Dec 21 '18 at 15:30

1 Answers1

0

To update your output in place you simply have to set the end keyword to a carriage return this way the vursdour will be returned to the start and overwrite the existing string.

I made a quick example script (with a timout so that the countdown can be seen

import time
count = 0
while True:
    print(count, end='\r')
    time.sleep(0.2)
    if count == 60:
        break
    else:
        count += 1
schtiehve
  • 16
  • 1