I've got something like this:
palindromes=[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 101, 111, 121, ..., 99799, 99899, 99999]
# of course im generating it :)
def isPrime(number):
for i in range(2,int(number/2)+1):
if number%i == 0:
return True
return False
def removeNonPrimes(palindromes):
for palindrom in palindromes:
if isPrime(palindrom):
palindromes.remove(palindrom)
return palindromes
palindromes = removeNonPrimes(palindromes)
And it doesnt remove all non primes
I can not figure out why