Problem not solved


Replace this line with your code. 
prices = {
    "banana" : 4,
    "apple"  : 2,
    "orange" : 1.5,
    "pear"   : 3,
stock = {
    "banana" : 6,
    "apple"  : 0,
    "orange" : 32,
    "pear"   : 15,

for key in prices:
    print key in prices
    print "price: %s" % prices[key]
    print "stock: %s" % stock[key]
for key in prices:
    print total
    total = total +  prices[key] * stock[key]
print total
error msg: its looks like your code did not print the correct total.


You have to define the function compute_bill(arg) and place your ONE for loop inside the function.


this type of function is not define in this exercise.plzz explain what does this function do??


My apologies, I couldn't see exactly how far in to the exercise you were. With the code you posted, here is the problem I see:

You would not need to tell it to print the key in prices here, because it is already performing the print function for those items. You would simply need it to

Where you say:

You wouldn't want to create a new dictionary just for the total cost, simply set total to equal 0.

Could simply be total += prices[key] * stock[key] if you chose to go this route.

Which instruction are you currently on? Step 11 should have had you create a function to perform this. Can you post a link to your current exercise step?


here is the link of my exercise


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