Okay, what am I doing wrong here? I'm generating primes from a list
and getting "list index out of range," but since the for loops
controls the indexes I don't see how that's happening. I thought it
was the list append, but I commented that out and put in a print
statement, and I still got the line 5 error:
primeList = [1]
numList = list(range(2,101))
for e in numList:
for f in primeList:
if numList[e] % primeList[f] != 0: #list index out of range
primeList.append(numList[e])
print(primeList)
--
Jim Mooney
The Real Reason Things Keep Going Wrong:
At the beginning of time, God set a Magic Top Spinning... and spinning...
and spinning... and spinning... and spinning... and spinning... and
spinning...
After a few hundred million years God got bored and gave the top a good
kick; so it went rebounding away, flinging off planets and stars and
dinosaurs, and later, people who wrote about dinosaurs.
Then God realized that although Order and Regularity are virtuous, if you
want interesting stories, now and then you have to give things a good Kick!
This explains a lot.
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor