I was just messing around and I have the following code:
from time import sleep
while True:
print('a', end=' ')
sleep(0.05)
For some reason, nothing is printed until I press Ctl+C. Then it prints everything it should have been continually printing. However, if I remove the end
argument:
from time import sleep
while True:
print('a')
sleep(0.05)
It works perfectly. "a" prints every 0.05 seconds.
Also, I don't have the problem with the first code when I leave out sleep
.
So: Why does the end
argument make sleep
hide output?