A day at the supermarket 8/13


#1
price = {
    "banana": 4,
    "apple": 2,
    "orange": 1.5,
    "pear": 3
    }
stock = {
    "banana": 6,
    "apple": 0,
    "orange": 32,
    "pear": 15
    }
    
for key in price:
    print key 
    print "price: %s" % price[key]
    print "stock: %s" % stock[key]

this is my code for that segment, the console keeps giving me the error
"Check what your code prints for 'o' it doesn't look quite right"

I am stumped and one get around this?


#2

Hi.

Please use the code tags so Codeacademy correctly formats the code so we can read it.

The only thing I can see wrong is that you have names the price of everything "price", and mine is "prices" and worked. Try chaning that.

P.S. - Please remember to indent properly


#3

I tried the following and it failed. I was trying to get in the habit of Python 3+ coding with () around my prints but codeacademy didn't like it. Once I removed them it passed.

    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])

#4

Hey there hammy, thanks for the reply, how do I use the code tags?

Also prices instead of price seemed to have solved it, thank you.


#5

Hey.

You can make use of the code tags when posting something by highliting your code, then clicking the </> button next to the "" button.

Please feel free to make use of the new like comment feature so people who had the same issue as you can see the resolution quicky :-))