Problem not solved


#1



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:
    total={}
    total=prices[key]*stock[key]
    print total
    total = total +  prices[key] * stock[key]
print total
error msg: its looks like your code did not print the correct total.


#2

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


#3

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


#4

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.
Also:

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?


#5

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

here is the link of my exercise


#6

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