I'm currently doing a projecteuler problem, which requires finding the sum of all the primes below two million.
I have a primitive function which determines whether or not a number is prime. This function is incorporated into the below function to produce a list with all the primes below the target:
def prime_target(target):
list = []
i = 0
while i <= target:
i += 1
if is_prime(i) == True:
list.append(i)
print len(list), list[-1]
I know this isn't efficient, but it's a quick and dirty method.
However, when I come to sum(list) in a later part of the code, I get the following:
Traceback (most recent call last):
File "euler-sum-primes.py", line 32, in <module>
total = sum(list)
TypeError: 'type' object is not iterable
But the list contains integers... and what is "type" type? I had a look through the documentation to find the answer, but it seems like I must be missing something obvious.
Any help much appreciated.