I'm getting a problem in printing the list values


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

for item in prices:
    print item
    print "price: ",  prices[item]
    print "stock: ",  stock[item]


Actually my data is getting printed, but its coming like " Oops, try again. Check what your code prints for orange. It doesn't look quite right! "
How to make it right and go ahead in codecademy


you did't print out the value number but only "price: " and "stock: "
try these

for fruits in prices:
print fruits
print "price: " + str(prices[fruits])
print "stock: " + str(stock[fruits])


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


thank you soo much, i got cleared with my question @amberson


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