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


#1

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


#2

ive tried " and ' it still doesnt work


#3

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


#4

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?


#5

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


#6

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

apple
price: 2
stock: 0

#7

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


#8

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


#9

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


#11

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


#12

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