Error in implementing Sieve of Eratosthenes
<p>I am getting an error in implementing 'Sieve of Eratosthenes' to get all the prime numbers between a specified range. I know my code is does not yet have primality checks, I will add them once I resolve the error.</p>

<pre><code>def foo(l,r):
    if l == r:
        return "Error"
    if l &gt; r:
        return "Error"
    if l &lt; r:
        pool = set(xrange(l,r + 1))
        prime = 2
        if l == 1:
            print "Discard 1 for now"
        while prime &lt;= r:
            rem = set(xrange(prime,r + 1,prime))
            pool.difference_update(rem)
            a = 0

            while prime &gt;= pool[a]:
                a = a + 1
            prime = pool[a]
        print pool

foo(1,31623)
</code></pre>

<p>ERROR:</p>

<pre><code>Traceback (most recent call last):
  File "D:\code\sieve_of_eratothenes.py", line 32, in &lt;module&gt;
    foo(1,31623)
  File "D:\code\sieve_of_eratothenes.py", line 27, in foo
    while prime &gt;= pool[a]:
TypeError: 'set' object does not support indexing
</code></pre>
