I may have your problem: if prime < 0: primes.append(x) else: print x, "is not prime. " # highlights the final " you have to separate each output with a comma, so try adding one after x.