Something of Value


#1



https://www.codecademy.com/courses/python-beginner-en-IZ9Ra/1/4?curriculum_id=4f89dab3d788890003000096

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


i can't understand why it pass an error, i looked in discuss section for the right code and also passing error when replacing any solution


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]


#2

you didn't anything from instructions !!!
Let's determine how much money you would make if you sold all of your food.

Create a variable called total and set it to zero.
Loop through the prices dictionaries.
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.
Finally, outside your loop, print total.


#3

sorry i didn't put the whole code

prices = {
"banana": 4,
"apple": 2,
"orange": 1.5,
"pear": 3

}

stock = {
"banana": 6,
"apple": 0,
"orange": 32,
"pear": 15

}

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

total = 0
for key in prices:

total = prices[key] * stock[key]

print total

#4

Same problem is happening with me also, any solution?


#5

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:
value = (prices[key] * stock[key])
print value
total = total + value
print total


#6

This worked for me;

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:
    value = (prices[key] * stock[key])
    total = total + value
    
print total