A day at the super market 8, Keeping track of the producs


#plz help I cannot figure out what is wrong with my code.


#ive tried " and ’ it still doesnt work


could you copy paste your code to the forum? This is python 2.7, so you don’t need brackets for printing, print (x) could become print x

Also, a space after the print keyword on line 17 and 18 is recommend. And, it should be price and stock, not prices and stocks, the printout should be an exact match

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

#This is it, is it just me or is it something internally?


As you can see the only thing I have changed (if you see something plz correct me) is i added an is after the price, and stock


The strings should be an exact match, for some reason you included is:

print "price is: %s" %prices[x]

should be:

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

same for stock, make sure it is an exact match to the result desired by the lesson: (from the instructions):

price: 2
stock: 0


I tried that, it gave me the exact same error.


Oh wait nvm I refereshed the page and it worked! THANK YOU SO MUCH IVE BEEN STUCK ON THAT FOREVER!!!


did you change both prices and stock and also payed close attention to ever character (spaces included)? Post an updated version of your code


Posting answers is not allowed, but for the rest, great you solved it :slight_smile:


Whops, sry didn’t know that, thanks again!