The point really is not to use len(a) but len(a)-1 as maximum. This also helps to understand why range(5) gives numbers 0 until 4.
>>> print a[len(a)]
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
IndexError: list index out of range
>>> for i in range(len(a)):