9. Problem with result :|


#1

Hello.

I really don't know what I am doing wrong here.
That's my 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
    print "price: %s" % prices[key]
    print "stock: %s" % stock[key]
    
total = 0
for key in prices:
    prices[key] = prices[key] * stock[key]
    print prices[key]
    total = total + prices[key]
print total

I think TOTAL is correct because when i calculate this manually i get the same: 117.

When I run this code I receive error message: Oops, try again. It looks like your code did not print the correct total.


#2

The above line is destroying your original data.

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

In the above, we are accumulating the value of each stock item in inventory without overwriting any data.