While loop error

mlorfeld matt at lorfeld.com
Fri Feb 1 01:08:25 EST 2002


I continue to get the error:
Traceback (most recent call last):
  File "Columbus:Desktop Folder:gaus.py", line 19, in ?
    n=list[i]
IndexError: list index out of range

my code is:
i=0
j=0
sum=0
list=[1,2,3,4,5,6,7,8,9,10,50,100]
list_length=len(list)
#G(n)=sum of first n natural numbers
while i < list_length:
	n=list[i]
	while j <= n:
		sum=sum+j
		j=j+1
	print sum
	j=0
	sum=0
	i=i+1

any ideas??



More information about the Python-list mailing list