Python. Project Euler Q35. Got a solution but I don't understand why other method doesn't work.
<pre><code>def rot_dig(x):
    y=''
    output=[x]
    listing=list(x)
    for i in range(1,len(x)):
        listing.append(listing[0])
        del(listing[0])
        for i in listing:
            y=y+i
        output.append(y)
        y=''
    return output

import math

def prime_is(x,prime):
    for m in prime:
        if m&lt;=math.sqrt(x):
            if x%m==0:
                return False
        else:
            return True


prime=[2]
for x in range(3,1000000):
    if prime_is(x,prime):
        prime.append(x)

primestr=[]
for x in prime:
    primestr.append(str(x))

sums=0
for x in primestr:
    count=0
    for y in rot_dig(x):
        if y in primestr:
            count+=1        
    if count==len(x):
        sums+=1
    ***else:
        for y in rot_dig(x):
            if y in primestr:
                primestr.remove(y)***

print sums
</code></pre>

<p>When run with the bold italic code the solutions miss the final rotation. So if it looks at say 1193, it includes 1193,3119,9311 but not 1931. I have spent a while trying to work out why but I don't get it.</p>

<p>I have since edited the code to make it much quicker and solved the problem I had by simply removing the block of code, but I can't understand why it happens since surely that block of code will only be executed on non circular primes.</p>

<p>PS I'm sort of new to programming so excuse my ignorance</p>

<p>Thank you</p>
