I am required to use the sum() function in order to sum the values in a list. Please note that this is DISTINCT from using a 'for' loop to add the numbers manually. I thought it would be something simple like the following, but I receive 'TypeError: 'int' object is not callable'.
numbers = [1, 2, 3]
numsum = (sum(numbers))
Have you used the variable
sum anywhere else? That would explain it.
>>> sum = 1 >>> numbers = [1, 2, 3] >>> numsum = (sum(numbers)) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'int' object is not callable
sum doesn't point to the function anymore now, it points to an integer.
Solution: Don't call your variable
sum, call it
total or something similar.