I am writing a program for Project Euler question 7 that attempts to find the 10001st prime. I adapted a script I already had that found all primes up to any number. It worked fine. But now I have a problem. My code repeats the list.
881, 883, 887, 1, 2, 3, 5, 7, 11, 13, 17, 19
that is from roughly the middle of my code.
max = int(input("What is your max no?: "))
primeList = []
while len(primeList) <= 10001:
for x in range(1, max + 1):
isPrime = True
for y in range (2 , int(x ** 0.5) + 1):
if x % y == 0:
isPrime = False
break
if isPrime:
primeList.append(x)
print(primeList)
What is causing this? Should I start from a blank canvas and not edit an old script?