# 9/13, What's wrong?

#1

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
print "price: %s" % prices[key]
print "stock: %s" % stock[key]
total = 0
total = stock[key] * prices[key]
print total

Oops, try again. It looks like your code did not print the correct total.

#2

You are not very far from the truth...

Your code returns a total for each particular type of fruit. Now you just need to add them all up together as the exercise expects a total equivalent to the worth of your entire inventory of fruits...

#3

Hey there @dezrukdaboss , so for this code I basically cheated this system haha.
"print 48.0 + 45 + 24 + 0" - was all I needed to type in and it let me pass through that checkpoint.

#4

It took me some time, but this is the loop that worked for me:

total = 0
for key in prices:
print key
print "price: %s" % prices[key]
print "stock: %s" % stock[key]
total += stock[key] * prices[key]
print total

#5

You got through the checkpoint but do you understand what the exercise wanted to teach you?

I see exercises more as a opportunities to learn something than as a series of hoops to jump through because in the end, what you will have learned will be your reward and believe me it will be much more usefull than a badge of completion

#6

I just never made total outside of the for loop which made it local. Lol

#7

That's what I'd do too

#8

It isn't that hard. You just have to initialize the total outside of the for loop and it is solved. You are cheating yourself, not the system