n = [3, 5, 7]

def total(numbers):

result = 0

for i in range(len(numbers)):

result +=i

return result

btw how to write codes like:

def aaa(b):

___print"thx"

n = [3, 5, 7]

def total(numbers):

result = 0

for i in range(len(numbers)):

result +=i

return result

btw how to write codes like:

def aaa(b):

___print"thx"

n = [3, 5, 7]

def total(numbers):

result = 0

for i in range(len(numbers)):

result +=i

return result

problem:

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

I was stuck on this problem for a long time but I realized that my issue was incorrect indentation. If your code looks correct, try playing around with the indentation. For me, it was the indentation for the result and return line on lines 6 and 7.

Just in case you need it, here's my code below:

n = [3, 5, 7]

def total(numbers):

result = 0

for i in range(len(numbers)):

result += numbers[i]

return result

print total(n)

This is the shortest I believe!

it works here

n = [3, 5, 7]

def total(numbers):

result = 0

for i in numbers:

result +=i

return result

print total(n)

or use

for i in range(len(numbers)):

result +=numbers[i]

i often forgot the indentations. thanks for the tips.

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

and my code works with/without the "print total(n)" (?)

That is also right but they want him in that section to learn how to utilise for loops in functions.

n = [3, 5, 7]

def total(numbers):

result = 0

# for i in numbers:

# result += i

return sum(numbers)

print total(n)

this isn't working for me

it gives the following error:

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

I realise the tutorial accepts one answer, and one only, even when the alternate answer is right according to the console. But why would the following not work:

def total(numbers):

____for i in range(len(numbers)):

________if len >= 2:

____________i[0] == i[0] + i[1]

____________del(i[1])

________elif len == 1:

________return i[0]

print total(n)

Thank you

Look at the code and find the difference:

n = [3, 5, 7]

def total(numbers):

result=0

for i in range(0, len(numbers)):

result += numbers[i]

`return result`

programing is about analysis if you don´t think an understand what one program those and a little change those another thing you will never learn get it!! it my thinking.

*Thanks for u ,as u say ,I do this ,It's worked*

n = [3, 5, 7]

def total(numbers):

---- result=0

----for i in range(len(numbers)):

---- ---- result+=numbers[i]

---- ----return sum(numbers)

print total(n)

*But this step is not workde (i think here is the indent problem )*

n = [3, 5, 7]

def total(numbers):

---- result=0

---- for i in range(len(numbers)):

--------result+=numbers[i]

---- ----return result *# left indent text 4 spaces is worked*

print total(n)

*like the flow step is all right:*

n = [3, 5, 7]

def total(numbers):

----result=0

----for i in range(len(numbers)):

---- ----result+=numbers[i]

----return sum(numbers)#or return result

print total(n)