12/15


#1

n = [3, 5, 7]

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

print total(n)

Oops, try again. total([0, 3, 6]) returned 0 instead of 9


#2

Hello austin

I think it is due to the indentation problems with your code. Below is the correct code which worked out for me

n = [3, 5, 7]
    def total(numbers):
        result=0
        for i in range(len(numbers)):
           result= result + numbers[i]
        return result
    print total(n)

#3

We can't help you if you don't post your code with proper formatting (I.e indentation, whitespace, etc) as it is impossible to tell what's what. From what I can tell this isn't for the 12/15 which makes it even harder to tell what you are trying to do as we have no instructions or anything to help.


#4

Python throws an indentation error if code is not indented properly as python works based on white space and indentation. The code posted has just been copied without any formatting.


#5

I believe that this is actually 15/15 and not 12. If so then I bet the problem is that the return statement is inside the for loop like below

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

When it should be outside the for loop as shown below

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

return result