I feel truly ashamed to not be able to figure this one out but this is killing me! I don't understand why my while loop condition isn't working. Based on the range in the initial for loop, I'm getting a variable number of terms (above 10001) after crossing the 105000 for the second number in range.
prime = []
terms = 10001
length = 0
while length <= terms:
for i in range(2, 110000):
isPrime = True
for j in range(2, int(i**0.5) + 1):
if i%j == 0:
isPrime = False
break
if isPrime:
prime.append(i)
length = len(prime)
print(length)
And the output turns out to be
10024
I tried using len(prime) initially and then created the variable length, as expected, it made no difference.
Please nudge me in the right direction to fix this error. 😫