# What am I doing wrong?

#1

Iterating over a list in a function

For the life of my, i don't understand what I'm doing wrong. I have the correct output displaying.

Code behaves correctly but does not pass the marking criteria.

``````n = [3, 5, 7]

def total(numbers):
result = 0

for i in range(len(n)):
result += n[i]
return result

print total(n)``````

#2

lets see:

``````n = [3, 5, 7]

def total(numbers):
result = 0

for i in range(len(n)):
result += n[i]
return result

print total(n)
print total([3, 8, 13])``````

the second function call should print 24, it doesn't

the function should work any list of integers supplied at function call, the key to solving this problem has to do with the function parameter (`numbers`)

#3

Ahh i mistook n with numbers ... my mistake.

``````n = [3, 5, 7]

def total(numbers):
result = 0
for i in range(len(numbers)):
result += numbers[i]
return result

print total(n)

print total([3, 8, 13])``````

#4

But do you understand why this change is important?

#5

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