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?
Asked
Active
Viewed 52 times
0
-
1A 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 Answers
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
-
Thanks, but is there any way to print it like:( x:y:count ). Like this. Kinda like a stopwatch? – RichardT Dec 21 '18 at 16:26