Question: I want to make a script which will type string letters one by one

```
def autotype(info):
    count = len(info) #Countign number of letters of the string
    splitlist = list(info) 
    i = int(count) #getting an error on this line! it accept i=int(0) but my loop doesnt work because of this
    while i>0:
        sys.stdout.write(splitlist[i])
        time.sleep(0.2)
        i -= 1

info = str("hello world")
autotype(info)

```

the error is: list index out of range
how do i fix it?

Answer: 
The length of a list is the number of elements in a list. But, lists start at index `0`, and so they will end at index `length - 1`. So, to fix your code as is, it should be `i = count - 1`. (You don't need to cast it to an `int`, it's already one.)

Better yet, rather than iterating using a counter in a `while` loop, just use a `for` loop. You can use the `for` loop to iterate over the characters in a string.

```
for ch in info:
    sys.stdout.write(ch)
    sys.stdout.flush()   # as mawimawi suggests, if you don't do this, it will
                         # actually just come out all on one line at once.
    time.sleep(0.2)

```

You also don't need to cast `"hello world"` to a string - it's already one.
Lists are zero-indexed, so the last element is at `len(info)-1`.

To fix this, you need to subtract 1 from the count:

```
i = int(count) - 1

```