9. Something of Value


#1

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 i in prices:
        total = stock[key] * prices[key]
print total

Look an Error:
Oops, try again. It looks like your code did not print the correct total.

Please I need help


#2

Hi, @muhozayves ,

Does your for loop correctly access the stock and prices dictionaries and add to each previous value of total as the loop iterates?

Is your indentation correct?


#3

Hi there, I had the same problem. I am not sure what your code looks like so I can't really see if there is a syntax error or a line item that is wrong etc. let see what you have for a code. That is how people who have heped me were able to do it.
Thanks Padewan


#4

prices = {
"banana" : 4,

}
stock = {
"banana" : 6
}

for key in prices:
print key
print "price: %s" % prices[key]

for key in stock:
print key
print "stock: %s" % stock[key]

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

its worked !!!..........check this


#5