Review my prime factorization function. Is it complete?
Your result is incorrect:

&gt;&gt;&gt; allPrimeFactors(360)
[2, 2, 3, 3, 5]
&gt;&gt;&gt; import operator
&gt;&gt;&gt; reduce(operator.mul, allPrimeFactors(360), 1)
180


It is also unnecessarily complicated.  The usual approach is, whenever you encounter a prime factor, extract as many powers of it as possible from the number.  Here's another function that works:

def reallyAllPrimeFactors(n):
    factors = []
    for i in range(2, n + 1):
        while n % i == 0:
            factors.append(i)
            n = n // i
    return factors
&gt;&gt;&gt; reallyAllPrimeFactors(360)
[2, 2, 2, 3, 3, 5]
&gt;&gt;&gt; reduce(operator.mul, reallyAllPrimeFactors(360), 1)
360


Further optimizations to that are possible, but it is already much more efficient than your original.  For one thing, it doesn't need to check any of its results for primality.  (Why?)