# Something of value is tricky

#1

not the correct total

``Replace this line with your code.``

#2

Usually with syntax errors (mostly in this section of your Python course), the problem is either forgetting to add a certain symbol (like commas ( `,` ) or colons ( `:` )), or typing one in the wrong place. But it's best to post your code so we can have a better look at it and find the problem.

#3

prices = {
"banana" : 4,
"apple" : 2,
"orange" : 1.5,
"pear" : 3,
}
stock = {
"banana" : 6,
"apple" : 0,
"orange" : 32,
"pear" : 15,
}
total = 0
for key in prices:
print key
print "price: %s" % prices[key]
print "stock: %s" % stock[key]

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

#5

take a look at:

Everything is stored in total, but you forgot something...

Instructions say (#3):

For each key in `prices`, multiply the number in `prices` by the number in `stock`. Print that value into the console and then add it to `total`.

Did you see the part in the instructions where they said, add it to total? You didn't add (`+`) total with/to your equation.

#6

``````i tried it, it didnt work

prices = {
"banana" : 4,
"apple"  : 2,
"orange" : 1.5,
"pear"   : 3,
}
stock = {
"banana" : 6,
"apple"  : 0,
"orange" : 32,
"pear"   : 15,
}

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

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

#7

Is your code indented? Could you possibly edit your post and wrap your code in `Preformatted text`?
The preformatted text icon that looks like this: `</>`. Or you can post a snapshot of your code.
I tested your code and it worked for me (with indentation).

#8

Ah, I see the problem. Some of your code isn't indented under your loop.

#9

Why do you need to have total added to the prices[key] * stock[key]? Why can't you just have prices[key] * stock[key]?

#10

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