Skip to content
← Back to Community
How Do I make a sentence letter by letter?
Profile icon
P0GCHAMPB0i

How Do I make a sentence letter by letter? For example: you typing "Hello World!"

Answered by Bookie0 [earned 5 cycles]
View Answer
Voters
Profile icon
bot111222
Profile icon
figglediggle
Profile icon
P0GCHAMPB0i
Comments
hotnewtop
Profile icon
Bookie0

Oh you mean type writer effect:

import sys, os, time st = 0.04 # interval between each letter def sp(str): # putting it in a function with a str as parameter for letter in str: # for loop that loops for each char in the string sys.stdout.write(letter) # outputs that letter sys.stdout.flush() time.sleep(st) # pauses print() # to use: sp("Hello World!") # will output each letter with 0.04s interval

Is this what you wanted? Let me know! :D

Profile icon
P0GCHAMPB0i

@Bookie0 ok i will try

Profile icon
P0GCHAMPB0i

@Bookie0 TYYYY

Profile icon
Bookie0
Profile icon
Bookie0

@B1gB0i np, glad it helped! :)

Profile icon
P0GCHAMPB0i
Profile icon
P0GCHAMPB0i
Profile icon
Bookie0
Profile icon
P0GCHAMPB0i
Profile icon
P0GCHAMPB0i
Profile icon
P0GCHAMPB0i

@Bookie0 lol these to videos are good click this one first: https://www.youtube.com/watch?v=dQw4w9WgXcQ

Profile icon
Bookie0

@B1gB0i they are obv rick rolls

Profile icon
P0GCHAMPB0i
Profile icon
P0GCHAMPB0i

@Bookie0
image

Profile icon
Bookie0
Profile icon
P0GCHAMPB0i
Profile icon
P0GCHAMPB0i

@Bookie0 eee get rickrolled

Profile icon
P0GCHAMPB0i

@Bookie0 ahh lets not get off topic

Profile icon
Bookie0

@B1gB0i ok i think that's enough lol ;)

Profile icon
P0GCHAMPB0i

@Bookie0 yup (sorry for all of these pings)

Profile icon
SilvermoonCat

Hi! I know this has been answered but (in my opinion) there's an easier way-

import time, sys def typing(text): for char in text: sys.stdout.write(char) sys.stdout.flush() time.sleep(0.043) # You can adjust speed print("") # new line typing("Hello World!")
Profile icon
xxpertHacker

If you want a more "human" type-writer effect, you might want to add a bit of randomization to the timing of the accepted answer.

Profile icon
Kai_Justice
import time def slowType(txt: str, buff: float = 0.5): # 'txt' is what you want to type out, 'buff' is the time between each letter for index, char in enumerate(txt): print(char, end="" if index+1 < len(txt) else "\n", flush=True) time.sleep(buff)

Usage: slowType("Hello world!", 0.03)

Profile icon
lsikora

What do you mean by letter by letter? What language? If you want to say hello world, you say...

print("Hello World!")

Profile icon
lsikora

This is python btw @CodeMaster007

Profile icon
P0GCHAMPB0i

@CodeMaster007 yeah but like when you type it it geos a sigle letter then another single letter

Profile icon
P0GCHAMPB0i

@CodeMaster007 Yea python

Profile icon
lsikora

Like this? @B1gB0i

print("H e l l o W o r l d !")