Something of value, PLS HELP


i am clueless on this one!


Start by creating the two dictionaries given in the instructions.

stock = {

prices = {



already done in previous problem
will we have to create a function for its solution>?


from the previous code, you just need to assign the value from variable total by multiplying each value from stock and prices dictionary. you can do it by the following code

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

after assign the value of variable total, all you need to do is kindly print the result. Hope this help


total = 0

for key in prices:
print key
print "price: %s" % prices[key]
print "stock: %s" % stock[key]
for key in prices:
total = total = total + prices[key] * stock[key]
print total


One too many assignments.

total = total + ...


sorry it was bey = total + prices[key] * stock[key]


That should work. Did it?


yes, It work properly. :smiley:


That's good. Be sure you take the time to study Python Math operators. It will expand your understanding, especially once you get to compound assigments.


This give me the full result:

But what if i only want the final result, how can i do?

I think thay maby i need to "return" the result of all the multiplications by separate, with out print and then print the final result.
total 1: prices[key] * stock[key]
total 2: prices[key] * stock[key]
total 3: prices[key] * stock[key]
final total: total 1 + total 2+ total 3

it`s that correct?, can i do something like this?

Srry but i`m new and i can traslate this think on a code.