15, Iterating over a list in a function


#1

Hi, i'm really lost in this one, i don't know what to do :sob: :sob: do i have to add or delete something? i'm really stuck!!

n = [3, 5, 7]

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


#2

ohhhhhh, nevermind, i found out what it is, i'm so stupid :sweat_smile:
when adding the numbers to result, i needed to write numbers[n] not just n heheheeh....


#3

Yeah, good debugging :wink:


#4

thx :blossom: :blossom:


#5

no problem. have a good day


#6

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