-1

a = [1,2,3] for i in a: print (i)

here is a simple code I would like to delay the print result while the for loop goes through the list. meaning I want a delay between the value 1 and 2 in the list item

  • Does this answer your question? [How do I get my Python program to sleep for 50 milliseconds?](https://stackoverflow.com/questions/377454/how-do-i-get-my-python-program-to-sleep-for-50-milliseconds) – Mahé Jul 08 '20 at 22:42

1 Answers1

0

Use the sleep function inside the time module:

from time import sleep

a = [1, 2, 3]
for i in a:
    print(i)
    sleep(0.5). # Sleeps for 0.5 seconds 
Mustafa Quraish
  • 692
  • 4
  • 10
  • There is a dot after the sleep, not a big impact for code reading but it sure raises exception. – okie Nov 03 '20 at 11:01