My apologies for asking dumb question.

I am learning Python through videos and books and really have no other help.

Can't figure out the simple differences on basic python programming.

########################################AAAAAA

```
    costs = [5,10,15,20]

    def sum_cart(item):
        total_cost = 0
        for this in costs:
            this = this + total_cost
        return total_cost
    print sum_cart(costs)

```

########################################BBBBBB

```
    def sum_cart(item):
        total_cost = 0
        for this in costs:
            total_cost = this + total_cost
        return total_cost
    print sum_cart(costs)

```

#########################################CCCCCC

```
    def sum_cart(item):
        total_cost = 0
        for this in costs:
            total_cost = this + total_cost
            return total_cost
    print sum_cart(costs)

```

-----------QUESTION-----------

The result is A --> 0, B --> 50, C --> 5

I am still confused why the result appears as is.

If my understanding is right, in A, 'this' gets 5 from the list, and 5 is added to total\_cost, which is 0. 'this' then calls 10, 15, and 20 respectively and 'this' gets a new value. However, because the total\_cost is still 0, the result is 0. Am I right?

Then in B, the total\_cost is updated when 'this' = 5 is called and added to the current 'total\_cost' = 0, which is 5. The loop goes back and brings in 10, 15, and 20 respectively and the 'total\_cost' is updated to 50. So far so good, I think.

But then in C, I am unsure what's going on because 'total\_cost' is updated when 'this' brings in value of 5 from the list. It then should returns 'total\_cost' to 5. Shouldn't the for-loop go back and do total\_cost = this (supposedly 10) + total\_cost (currently 5) and do the loop again? What am I missing about the "return" function?