It's because of output buffering. The buffer isn't flushed until a newline is printed. Since you used end=' '
, there's no newline after each word, so the buffer isn't flushed until the script ends.
You can use the flush=True
option to force it to flush immediately.
import time as t
import sys
print('hello', end=' ', flush=True)
t.sleep(1)
print('hello', end=' ', flush=True)
t.sleep(1)
print('hello', end=' ', flush=True)
t.sleep(1)