+ 3
Typewriter effect on inputs (python)
So I learned how to get python to print strings horizontally over a certain period of time instead of putting out the entire string at once. Like the interface is typing: import sys,time,os message = ("hello world!) for char in message: sys.stdout.write (char) sys.stdout.flush() time.sleep (0.1) What I'm trying to figure out it how to get it to respond to input by using the same method but when I do: import sys,time,os message = input ("hello world!) for char in message: sys.stdout.write (char) sys.stdout.flush() time.sleep (0.1) It just prints everything out at once again. Anyone know how to fix? Thanks!
7 Answers
+ 4
I got new notified on this thread again, so I decided to read the OP question once again and now I think i understand what he meant...you can simply try this
Import time
a = input("enter your name : ")
for char in a:
time.sleep(.1)
print(a, end="")
+ 6
Try:
message = input() or "hello world"
for char in message:
sys.stdout.write(char)
sys.stdout.flush()
time.flush(0.1)
----------alternatively-----------
for i,x in enumerate(message):
sys.stdout.write(x)
sys.stdout.flush()
time.flush(0.1)
+ 3
OP came back after 1yr to verify an answer lol
0
Works if I don't put input. Something about that input is messing it up...
0
Hey! I have the same problem. It looks like when I run it through the text of an input, it wants to return “None” before the user can enter an input.
Did you find a solution to this?
0
Mirielle[Inactive] nice! After I posted this I came to another solution: use whatever you need to for the typewriter effect, then set the input as simply “ “. So the typewriter effect only affects a string, and the imput is just a space occurring between the sentence and the actual input.
0
Sorry bout that lol