Pythonic Prime Generation
Use Python's math library

You can either import the whole math library, or just import the modules you need.

from math import sqrt, floor


Use a dictionary instead of a list

Yes, if b*c in a iterates through the list. However, if you use a dictionary, it takes only a single operation to look up any value. This is because Python stores dictionary keys and values as a hash table.

You can use Python's dict comprehension syntax.

d = {key: value for (key, value) in iterable}


The result looks like this:

from math import sqrt, floor

def prime_gen(n):
    a = {k: 0 for k in range(2, n+1)}
    for b in range(2, floor(sqrt(n))):
        c = 2
        while b*c &lt;= n:
            if b*c in a:
                a.remove(b*c)
            c += 1
    return(a)