What's wrong in the code?


#1

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


#2

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


#3

Thanks a lot stetim94!


#4