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: 
You're starting your loop at `i=len(info)`, which is one more than the final index in the string. The last index in a string (or other iterable) is `len(string) - 1`, because indices begin at `0`.

Note that in Python, you can (and are encouraged to) make use of the natural language constructs and the fact that collections are easy to iterate over:

```
for letter in reversed(info): # Much clearer way to go backwards through a string
    sys.stdout.write(letter)

```

---

Since you've clarified in your comments that you actually want to go forwards through the text, you can just take out the `reversed` bit. The code as you posted will iterate backwards through the text, not forwards -- another benefit to using the standard iteration techniques is that it's much easier to see if you've done something you didn't mean to do!

```
for letter in info: # Very clear that you're going forward through the string
    sys.stdout.write(letter)

```

---

Finally, as others have mentioned, you should add an explicit call to `sys.stdout.flush()` after every write, because otherwise there's no guarantee that you'll see output at regular intervals (it could be written to the buffer but not flushed to the screen until much later).
Unidiomatically, but concisely:

```
import time
import sys

autotype = lambda instr:map((lambda ch:(sys.stdout.write(ch), time.sleep(0.2))), instr)

autotype("hello world")

```

The main problem with the above code is that it's not usual to sequence two functions using tuple if you don't care for their return values.