Skip to content Skip to sidebar Skip to footer

Python For Loop: "list Index Out Of Range" Error?

I have a code, based on problem 3 from Project Euler: 'The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143?' I have a code

Solution 1:

You probably meant to do:

for j in range(len(res)):
    for k in range(2,res[j]):

Using for j in res will iterate over res elements.

Post a Comment for "Python For Loop: "list Index Out Of Range" Error?"