title: Trying to generate primes from 1 - n, but consistently is missing primes 3 and 5.?
body: <pre><code>def generate_primes(n):
      """generate_primes(n) -&gt; list
      Returns a list of all primes &lt;= n."""
      from math import sqrt
      primes = [2]
      potentialPrimes = []
      for x in range(3, n + 1):
          potentialPrimes.append(x)
          if x % 2 == 0:
              potentialPrimes.remove(x)
      currentPrime = potentialPrimes[0]
      primes.append(currentPrime)
      while currentPrime &lt; sqrt(n):
          for x in potentialPrimes:
              if x % currentPrime == 0:
                  potentialPrimes.remove(x)
          currentPrime = potentialPrimes[0]
      for x in potentialPrimes:
          primes.append(x)
      print(primes)
  
  generate_primes(100)
  </code></pre>
  
  <p>When I try to call the function, it prints this:</p>
  
  <pre><code>[2, 3, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
  </code></pre>
  
  <p>Any idea why?
  And any ways to improve my code would be much appreciated as well.</p>