A Day at the Supermarket


#1


im stuck on this excercise its telling me orange is giving the wrong output but its not ....does anyone see my issue

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

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

orange
prices 1.5
stock 32
pear
prices 3
stock 15
banana
prices 4
stock 6
apple
prices 2
stock 0
None


Replace this line with your code. 

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


#2

"print out the key along with its price and stock information. "

looks like you need price instead of prices


#3

Loop through each key in prices.
Like the example above, for each key, print out the key along with its price and stock information. Print the answer in the following format:
apple
price: 2
stock: 0
Like the example above, because you know that the prices and stock dictionary have the same keys, you can access the stock dictionary while you are looping through prices.

When you're printing, you can use the syntax from the example above.

the dictionary is named "prices" so that cant be it


#4

Are you so sure about that?

Step 2: "Like the example above, for each key, print out the key along with its price and stock information. Print the answer in the following format:"

When I add, in my passed lesson, an s to price in my print statement I get this error: "Oops, try again. Check what your code prints for orange. It doesn't look quite right!" When I take the s out, I pass the lesson. Seems like this is the same wouldn't you say?


#5

i did that still doesnt work


#6

post your full code again please?


#7

ok this is my adjusted code

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

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

for x in price:
print x
print "price %s" % price[x]
print "stock %s" % stock[x]

result output

orange
price 1.5
stock 32
pear
price 3
stock 15
banana
price 4
stock 6
apple
price 2
stock 0
None


#8

lol it was missing the ":"

in print "price %s" % price[x]
print "stock %s" % stock[x]


#10