- #1
- 49
- 0
I don't know why we have to write a sum function for python when there already is one but
this is supposed to sum a list with varible values and I don't understand why it doesn't work, can someone help explain there error, I believe that I am not giving proper values to the line that adds but I don't realize why<
this is supposed to sum a list with varible values and I don't understand why it doesn't work, can someone help explain there error, I believe that I am not giving proper values to the line that adds but I don't realize why<
The Attempt at a Solution
Code:
def sum_list (a_list):
length = len(a_list)
counter = 0
total= 0
while(counter < length):
(a_list[counter] +total)
counter = counter + 1
total = total + counter
return total
#testing the functions
my_list = [3,3,3]
print sum_list(my_list)