Reputation: 49
import time
for i in range(100):
print('*',end='')
time.sleep(0.1)
why this code is not working for showing progress? Expected output was to be showing a progress '****************'.
Upvotes: 0
Views: 638
Reputation: 38857
Stdout is buffered. You can flush it with a call to sys.stdout.flush()
after each print
. Or you can add flush=True
to your print command instead of doing an explicit flush:
print('*', end='', flush=True)
Upvotes: 1