Keeping Track of the Produce


#1



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


I keep getting an error message that says "Oops, try again. Check what your code prints for orange. It doesn't look quite right!" although I looked at other questions about the same exercise and I'm not sure what I'm doing wrong :confused: here's what I have:


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 "prices: %s" %prices[item]
       print "stock: %s" %stock[item]


#2

You probably printed something slightly differently, compare what you printed to the format shown in the instructions. It's about 20-30 characters so it's very reasonable to make an exact comparison by eye.


#3

it looks pretty much the same to me :confused:


#4

That's not enough when it needs to be exactly right


#5

it does seem to be exactly the same


#6

Did you compare character by character? One at a time? You must not have. Step up your comparison game.


#7

.........yes, I did.


#8

These are different:

orange
prices: 1.5
stock: 32

orange
price: 1.5
stock: 32

Looking at those I can immediately tell that the lines have different lengths. Your method of comparison needs to change.


#9

You have to remove the "S" from "price:%s" not "prices:%s"

Correct answer:
print key
print "price: %s" %prices[key] -
print "stock: %s" %stock[key]


#10

ohhh okay I see. I didn't realize that it would make a difference. thank you so much!!! :smiley:


#11

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