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


#1



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


`python

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

stock = {
"banana": 6,
"apple": 0,
"orange": 32,
"pear": 15
}
for apple in prices:
print "apple"
print "Price: %s" % prices["apple"]
print "Stock: %s" % stock["apple"]

Help pls!
I added variable X


#2

Suggest use a generic variable, and not apple.

for item in prices:

Now use the variable without quotes in the dictionary accessor...

prices[item]
stock[item]

Be sure to print all lowercase (see the example in the lesson text).


#4

Please do not edit your post once you receive a reply. Post new code in a reply.

You still have upper case in your print out.


#5

print "price:", prices[x]
print "stock:", stock[x]

#6

The exercise expects string formatting.

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

#7

Thank you . The correct code came out


#8

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