11 A day at the Supermarket


#1



My code isn't completing in exercise 11. I get an 'dict' object is not callable error. See the code


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


Oops, try again. compute_bill(['apple']) resulted in a TypeError: 'dict' object is not callable


def compute_bill(food):
    total = 0
    for mark in food:
        total = total + prices(mark)
    return total
n = [4, 1.5, 0]
print sum(n)


#2

Hi, @mriguana ,

Temporarily add this line at the end of your code, in order to call your function for testing purposes ...

print compute_bill(shopping_list)

Always take a look at the console after you submit code. Error messages will typically include one or more line numbers where problems were detected. The line number that is mentioned last is an important place to look for an immediate cause of the error, so that is a good place to concentrate first. Also devote close attention to this ...

'dict' object is not callable

After you have found the problem, you can remove or comment out the line that was added for testing. Let us know what you found.

EDITED on July 15, 2016 in order to add details.


#3

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