def isprime(n):
    for i in range(2,n-1):
        if n%i == 0:
            return False
    return True

def putn(n):
    p = []
    for i in xrange(1,n):
        if isprime(i):
            p.append(i)
    return p

This code is part of the book "Python for Bioinformatics", by Sebastian Bassi (sbassi@genesdigitales.com). Return to home page.