Ask coding questions

← Back to all posts
0
I have a question about python.
PAULX (16)

when i make

print("Hi world")

than it prints that all at the same time, how can i make it that i looks like writing also i mean with a delay from every character to character.

Answered by Pythonier (299) [earned 5 cycles]
View Answer
Commentshotnewtop
2
Pythonier (299)

Try using sys.stdout.write() and using a for loop to sys.stdout.write() each character. Make sure you also use time.sleep()

1
Vandesm14 (485)

Wha? He left the post without marking it as answered!

1
ReshiramWolfu (60)

Can you give me a link to your code please?

1
TheDrone7 (515)

For that purpose, you might wanna use the sleep() function of the time library that comes built-in with python. You can learn more about how to use it at - https://www.programiz.com/python-programming/time#sleep

1
MATTHEWBECHTEL (121)

I was going to say the same thing, but I don’t know how to use it like say h (wait) I. I can only use time-sleep commands like hello there (wait)[next line] how are [email protected]

1
TheDrone7 (515)

@MATTHEWBECHTEL you can iterate over the string for example;

for s in "Hello World":
    print (s)
    # wait now
1
MATTHEWBECHTEL (121)

Ok I’ll try it later thanks.
Upvote my comment if it helps or you just wanted to upvote.
@TheDrone7

1
TheDrone7 (515)

@Pythonier
your answer sort of goes against the helping rules.

1
Pythonier (299)

@TheDrone7 oops haven't seen that yet, I'll change my response. Thanks for the info.