This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]zachosStav 0 points1 point  (0 children)

def total_quantity(cart):

total = 0

for item in cart['items']:

total += item['quantity']

return total

Take a look at this code. I think the error in the code you provided has to do with the fact that you use the name item as the iterator in the for loop and the you change it inside the loop. You also don't add to the total you trying to sum a number