I'm trying to create a program, where it types whatever needs to be typed, and sometimes it makes a mistake which it corrects, as if an actual person is typing, here is my code:
import time
import sys
import random
import string
import uuid
def my_random_string(string_length=4):
random = str(uuid.uuid4())
random = random.lower()
random = random.replace("-","")
return random[0:string_length]
def delay_print(s):
for c in s:
sys.stdout.write( '%s' % c )
sys.stdout.flush()
time.sleep(random.uniform(0.01,0.5))
random_string = random.randint(0,6)
if random_string == 5:
sys.stdout.write(my_random_string(2))
time.sleep(0.1)
#delete the two characters
delay_print("Hello, and welcome to the Enrichment Centre")
I don't know how to delete the two characters that I placed.