newbie question on lists, getting an error on basic addition

John Warney john at yahoo.com
Sun Mar 31 12:07:04 EST 2002


>>> alist = [1, 2, 3, 4]
>>> counter = 0
>>> answer = 0
>>> alist
[1, 2, 3, 4]
>>> counter
0
>>> answer
0
>>> while counter < 6:
... 	answer = answer + alist[counter]
... 	counter = counter + 1
... 	
Traceback (most recent call last):
  File "<interactive input>", line 2, in ?
IndexError: list index out of range
>>> answer
10



why am i getting this error when it works???
Rob



More information about the Python-list mailing list