I want a text to be displayed as if it is just being typed. So I need a little delay after every letter.
I tried to do it this way:
import time
text
You are printing the result of time.sleep(0.2)
, which is None
. Move it to the next line.
text = "Hello, this is a test text to see if all works fine."
for char in text:
print char,
time.sleep(0.2)
Of course, you still have the problem of a space between each character, which can be solved by replacing the print
statement with a call to sys.stdout.write
.
text = "Hello, this is a test text to see if all works fine."
for char in text:
sys.stdout.write(char)
time.sleep(0.2)