`Replace this line with your code.`

# 15/18 iterating over a list in a function

**legoman232**#2

n = [3, 5, 7]

```
def total(numbers):
result = 0
for i in range(len(numbers)):
result = sum(i, result)
return result
```

It says total [0,3,6] resulted in an error : 'int' object is not iterable.

**i-3-coding**#3

have you indented properly? I'm stuck on the same exercise, so help would be appreciated

**stetim94**#6

but now you don't understand why your code is wrong, there are two problems, `sum()`

expects a list (or something it can loop over) and returns to you the result, for example:

`print sum([0,1,2])`

you can't loop over integers, so `some()`

gives an error, so you will need a different way of adding to total

second problem, `i`

contains the indexes of the list, not the actually numbers, you will need the index to get the item from the list to add to total

**system**#8

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.