15. Iterating over a list in a function


#1

https://www.codecademy.com/courses/python-beginner-nzzVa/3/4?curriculum_id=4f89dab3d788890003000096

Have no idea what I'm doing wrong. Can anyone help pls?


n = [3, 5, 7]

def total(numbers):
    result = 0
    for number in n:
        result += number
    return result


#2

Hi @myeates,

Instead of this ...

    for number in n:

... what you need to do is iterate through numbers ...

    for number in numbers:

Then this statement inside the loop will work correctly ...

        result += number

#3

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