primes = [2,3,5,7]
for n in range(10, 10000):
isPrime = True
for d in primes:
if (n % d) == 0:
isPrime = False
else:
primes.append(n)
break
print(primes[n])
I have to print all the prime numbers from 10 to 10000 and then append them to the given array of first few prime numbers. My code was working earlier as I tested it multiple times. Now it throws me an an error "list index out of range". Not sure what's wrong thought I was on the right track.