12/15 Iterating over a list in a function helpe


this is my code
n = [3, 5, 7]

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

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


The for loop you created will just be numbers at each iteration. The intent here is that each number is a valid index in the given list. hence you must modify this line

result= i +result

to be

result= numbers[i] +result

n = [[1, 2, 3], [4, 5, 6, 7, 8, 9]]
# Add your function here
def flatten(lists):
    for numbers in lists:
        for x in numbers:
    return results

print flatten(n)