I thought sum a list of numbers in Python would answer my question but it didn't.
For context, I am working on Project Euler, Problem 9: https://projecteuler.net/problem=9
I am getting the error
TypeError: unsupported operand type(s) for +: 'int' and 'list'
for the line
while sum(triplesList) <= 1000:
I don't know why sum(listname)
isn't working.
Here is all the code:
triplesList = []
a = 0
b = 0
while sum(triplesList) <= 1000:
a += 1
b += 1
triplesList = [[a,b] for i in range(1)]
triplesList.append( a**2 + b **2)
if (math.sqrt(triplesList[1])).is_integer():
triplesList[1] = int(math.sqrt(triplesList[1]))
if sum(triplesList[0], triplesList[1]) == 1000:
print triplesList
print sum(triplesList[0] , triplesList[1])
print reduce(lambda x, y: x * y, triplesList[0], triplesList[1])
I appreciate the help!