Something of Value


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 += prices[key]

print total

The total it's giving me is 117, which to me is correct unless I'm totally missing something.
But I'm still getting this error: Oops, try again. It looks like your code did not print the correct total.


Read the instruction carefully !!
It say "For each key in prices, multiply the number in prices by the number in stock. Print that value into the console and then add it to total."
which means first you have to print the value which is equal to price*stock! and then you have to add that value to the total variable and then you have to print that total!!
The output will give you the total value for each item in stock and then at last it will you the total sum of the values of different items that you have in stock!
The code should look like this!