Can’t figure out how to fix "list index out of range"

  python

Here is my code:

keys = input('Enter sentence to repeat type')

try:
    keyslist = keys.split(' ')
    length = len(keys)
    while True:
        if keyboard.is_pressed('`'):
            quit()
        
    i = 0
    while i < length:
        keyboard.press(keyslist[i])
        i = i + 1
        time.sleep(0.01)
    time.sleep(0.08)

except Exception as exp:
print(exp)
selection()

I’m trying to get it to keep typing the same thing over and over. But when I run the code I get "list index out of range" How do I fix this?

Source: Python Questions

LEAVE A COMMENT