[SOLVED] 15/18 I think it hates me


#1

I'm pretty sure this is right, even if I don't completely understand the range function yet.

   n = [3, 5, 7]

def returnSum(numbers):
    result = 0
    for i in numbers:
        result += numbers(i)
    return result

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

I get an error in the "total" function. Help?


#2

uhhmmmmmmmmmmmmm okay lol fixed it.

has to be changed to elements += numbers[i]


#3

n = [3, 5, 7]

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


#4

I was having the same issues.

I would say correct the result += numbers(i) to result += numbers[i]
and
elements += i to elements += numbers[i]

n = [3, 5, 7]

def total2(list):
(indent) result = 0
(indent) for i in list:
(indent)(indent)result += listireturn result

def total(number):
(indent) result = 0
(indent) for i in range(len(number)):
(indent)(indent) result += numberi return result