Iterating over a list in a function


can any one tell me where my code went wrong?when i use second method.


The range you are adding is, [0, 1, 2], the indices. Add numbers[n].


now i have to add 3. is it correct


You have to add the values in the list, not the indices from the range.

for i in range(len(numbers)):
    result += numbers[i]


kk,i got it.Thank you


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