What's wrong in the code?


for key in prices:
product = prices[key] * stock[key]
print product

print 48 + 45 + 24 + 0

error comes that sum is not correct, please help


you want to calculate what it cost to buy all products in store, here:

product = prices[key] * stock[key]

this will just assign a new value to product, you should add prices[key] * stock[key] to the value that already is in product

for this to work, you will also need to define product first outside the loop, give it a value of 0


Thanks a lot stetim94!