Ask coding questions

← Back to all posts
I need help slowing down a python loop
ia13ru (43)

Hi,
I am makin this game. I want to slow down the 'for i in range(3) ' loop in ' if key==""'. How do I do this?

Comments
hotnewtop
Coder100 (18185)

you could use time.sleep to make it wait.
don't forget to also add import time

ia13ru (43)

@Coder100 Where? I am also using tkinter

Saml2020 (51)

@ia13ru time.sleep() Pauses the whole program. So if you want to slow down a loop, put it at the end or start inside of the loop.

Coder100 (18185)

inside the loop!

while ...:
  ...
  time.sleep(1)

@ia13ru

ruiwenge2 (595)

you can use this:

import time

# insert code here
time.sleep(1)

You can change the 1 to however many seconds you would like.

ch1ck3n (2065)

Can you be more descriptive