Something of value, PLS HELP


#1

i am clueless on this one!


#2

Start by creating the two dictionaries given in the instructions.

stock = {

}
prices = {

}

#3

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


#4

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


#5

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


#6

One too many assignments.

total = total + ...

#8

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


#9

That should work. Did it?


#10

yes, It work properly. :smiley:


#11

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.


#12

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.
like:
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.


#14