A day at the super market


#1



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

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

it says "Oops, try again. Check what your code prints for orange. It doesn't look quite right!"


#2

the output needs to be an exact match, you miss a space after your colon for price and stock


#3

would you write it down? it doesn´t works for me


#4

no, that is the violation of the guidelines

can i see an updated version of your code?


#5

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

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

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

IT´S NOT A SYNTAX ERROR, IT SHOWS PERFECTLY THE SAME THAT THE EXCERSISE IS ASKING TO ME IN THE EDITOR


#6

there is a space missing between price: and %s, like i said in the first reply. Same for stock. Exact really means exact


#7

KINDLY HELP OUT PLEASE

Dictionary

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

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

for item in prices:

print "prices: %s" % prices[item]
print "stock: %s" % stock[item]

OUTPUT :Oops, try again. You should have exactly three print statements! (Make sure there are no occurrences of 'print' in any comment or string!)


#8

you also need to print the item, and here:

print "prices:

a product has a price:, not prices:


#9

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