# 9. Something of value

#1

#2

While you are reaching the correct total, my guess is it's unhappy because of the way you are reaching that total. What your for loop is doing is actually changing the value of the prices key so that it is multiplied by the stock level. So after the for loop runs your prices dictionary becomes incorrect, because it reflects the price times the stock level. The reason your total is technically correct is because you are taking the updated price key and cumulatively adding it to the total.

Try changing your for loop so that instead of changing the value of the prices key you just add the value of `prices[key] * stock[key]` to the total and see if that works.

#3

Yeah, that works, I came up to it by myself after some attempts. Thanks for reply, anyway)

#4

I need help figuring out how to add the amount i get after multiplying the stock and the price. I have been stuck on this for a while so i am really desprate for an answer

#6

I got it:

for key in prices:
prices[key]*stock[key]
total= prices[key]*stock[key]+total
print prices[key]*stock[key]+total
print total

the bold line adds the stock and price and sets it to the total's value

#7

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