0

Was giving Sieve of Eratosthenes - Finding Primes Python first answer's code a try but unable to return or print any value.

Only output is "generator object sieve at..."

Solutions I found were creating a list of the values and returning that but still nothing.

How can I get this code to return / print a list of primes?

def sieve(limit):
  count = [False] * 2 + [True] * limit-2

  for (num, prime) in enumerate(count):
    if prime:
      yield num

      for ind in range(num*num, limit, num):
        count[ind] = False

  primes = [i for i in count if count[i]]

  return primes



print(sieve(10))
kenneh
  • 9
  • 1

0 Answers0