0

So i'm attempting to make a python program that prints something, then waits for a second, then prints something again. However it waits for a second initially, then prints both at the same time This is the program

import time

print("lol")
time.sleep(1)
print("lol")

Essentially, I am expecting this program to print lol, wait a second, than print it again. but instead it waits a second and prints both. I've tried with both before the time.sleep as well and it still waits the second.

Is this how sleep is supposed to work? I've seen from several examples it seems to work like the javascript wait() were it just waits for the time given.

1 Answers1

0

This is because of output buffering. You should turn it off.

This thread will help you: Disable output buffering

APhillips
  • 1,175
  • 9
  • 17