Hello Friends ! I am getting this message. Please help me!


Oops, try again. compute_bill(['apple']) resulted in a TypeError: unsupported operand type(s) for +: 'int' and 'str'


We're forced to guess what your problem is. You do realize that, right? Next time please provide some information that will help us quickly solve your problem or rather help you to solve your problem.

We've seen cases such as this,

def compute_bill(food):
    total = 0
    for item in food:
        total += item
    return total

This returns an error similar to the above. The way to repair this is to see that item is a string, and we cannot add a string to a number. What we need is the value in the prices dictionary that corresponds with the key of the same name as item.

total += prices[item]

This may be your problem. But, as earlier stated, it's just a guess.

  1. A link to the exercise
  2. Your attempted code
  3. The error messages