Something of Value


#1



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


Hi , i am having problem with my code ,
it's telling me :"It looks like your code did not print the correct total"


i guess that everything is right with my code but i don't know why it's giving me this


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

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

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


#2

HI you didn0t so what the lesson Something of Value aske you to do
01. Create a variable called total and set it to zero.
...


#3

I just did it but still giving me the same thing :frowning:


#4

Can you post your new code?


#5

It worked now :slight_smile:
That's my new code :
stock = {
"banana": 6,
"apple": 0,
"orange": 32,
"pear": 15
}

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

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

total = 0
for i in prices:
total = total + (prices[i]*stock[i])

print total

Thanks a lot !


#6

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