user4857240
user4857240

Reputation:

How to print slowly with a while loop in python 2.7.9

I am trying to print each iteration of the following loop more slowly (so that the person seeing the image printed can actually make out what it is before it goes away too quickly). Any help is welcome. The following code doesn't seem to slow anything down, even when I change the integer to a different number. I don't understand why it's not working.

 import time 
 while True: 

      print  """There are normally 55 lines of strings here, but for readability sake I have deleted them and inserted this text instead."""
 time.sleep(5)

Upvotes: 0

Views: 508

Answers (2)

danidee
danidee

Reputation: 9634

wrong indentation it should be

import time 

while True: 
    print  """There are normally 55 lines of strings here, but for readability sake I have deleted them and inserted this text instead."""
    time.sleep(5)

Upvotes: 0

Larry Lustig
Larry Lustig

Reputation: 50998

Because the call to sleep is outside the while loop, you'll run all the prints, and only then sleep the program.

Indent the call to sleep to include it in your loop.

Upvotes: 3

Related Questions