9. Something Of Value


#1

Hello all, once again! I seem to have gotten stuck on number 9. Could someone please explain what I've done wrong?

Error Message:
Oops, try again. It looks like your code did not print the correct total.(Total that is printed is 0.)

prices = {
    "banana" : 4,
    "apple"  : 2,
    "orange" : 1.5,
    "pear"   : 3,
}
stock = {
    "banana" : 6,
    "apple"  : 0,
    "orange" : 32,
    "pear"   : 15,
}

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


#2

Okay, the issue should be here:

You want to, for each key in prices, multiply the number in prices by the number in stock.

    total += prices[key]*stock[key]

#3

Thanks bayoishola20 , that fixed it.


#4

You're welcome @starwarsfan13 .

Have fun coding! :slight_smile:


#5

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