How do I get it to return per line, isn't that the point of this exercise? For instance, how would I get it to return each value, such as line 35's list "total = 0" on one line, next "total = 0 + 11", next line "total = 11+22".
I could not find a way to do it like, 'running_total = return item[0], return item[0] + item[1]...item[i]'.
First, it's good that you understand what you need to do and are referring to the last item of the list as item[i]
. Keep in mind that if the list is in the variable list
then to get the item at, say, index 10
, we want list[10]
, not item[10]
. Imagine if you could write code like this:
def sum(list)