Stuck even though I followed instructions exactly


#1



https://www.codecademy.com/en/courses/python-beginner-en-IZ9Ra/2/2?curriculum_id=4f89dab3d788890003000096


TypeError: cannot concatenate 'str' and 'list' objects


It should have returned the total of all foods.


def compute_bill(food):
    total = 0
    for total in food:
        total = total + food
    return total[key]


#2

This is in spite of me following all directions and even me checking the next part to see if I was correct (I was)


#3

total is already defined as the accumulator. Use a different variable in the loop.

    for item in food:
        total = total + food[item]

May also be written,

total += food[item]

They main thing is to accumulate the value for each item.


#4

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