Iterating over a list in a function


#1



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


total([0, 3, 6]) resulted in an error: can only concatenate tuple (not "int") to tuple


it should return the addition of the numbers


Replace this line with your code. 
n = [3, 5, 7]

def total(numbers) :
    result = 0 ,
   
    for values in numbers :
        result += values 
    
    return result


#2

there is comma after result= 0 ?


#3

try this
numbers = [3, 5, 7]

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

return result

#4

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