Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis+ 1
Code executed after time
I want to make a statement end with ā. . .ā (Example: print(āLetās play a game(dot)wait(dot)wait(dot)ā)But have each dot wait a second before appearing, to give the program a little bit of life. How would I go about doing this? I tried using sleep but it doesnāt work for me.
3 Respostas
+ 2
import time
print("The statement you want to output", end='')
for x in range(3):
print('.', end='')
time.sleep(1)
# or you can swap the two line in the 'for' loop around.
+ 1
have a look at the time module, sleep is in there.
0
rodwynnejones When I try time.sleep(1),ā.ā,
time.sleep(1),ā.ā, time.sleep(1),ā.ā
It prints out āNone . None . None .ā
What am I doing wrong?