So far the only method I've come up with is clearing the console then displaying the string with one more letter. Suggestions?
Current Code:
import os
import time
In=list(input("Text to be displayed: "))
Out=""
Move=[]
print("-")
while len(Move)<len(In):
Move+=["/","|","\\","-"]
for a in range(0,len(In)):
if In[a]==" ":
x=.3
elif In[a] in ",';:!@#$%^&*()_+-=[]{}":
x=.25
elif In[a] in "aeiouzxcvbnm1234567890AEIOUZXCVBNM":
x=.2
else:
x=.15
os.system('cls')
Out+=In[a]
print(Out+Move[a])
time.sleep(x)
os.system('cls')
print(Out)
input()
Just use print() with end='' to stay on the same line, and flush = True for the timing:
import time
Move+=["/","|","\\","-"]
text = input('Text to be displayed: ')
for i in text:
print(i, end='', flush=True)
time.sleep(0.1)
print('\n')
This runs as:
bash-3.2$ python3.3 test.py
Text to be displayed: This is a test
This is a test
bash-3.2$
import time
Move=["/","|","\\","-",""]
text = input('Text to be displayed: ')
for i in range(len(text)):
print(text[i]+Move[i%5], end='', flush=True)
time.sleep(0.1)
print('\n')
If I am understanding the question correctly, you just want the string to appear one character at a time, with a delay between each character.
import time
from sys import stdout
In=list(input("Text to be displayed: "))
for x in In:
print(x, end='')
stdout.flush()
time.sleep(0.1)
print("\n")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With