A Day at the Supermarket


#1

Getting an error for this exercise,
Please help

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

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

for key in prices:
print "prices: %s" prices[key]
print "stock: %s" stock[key]

this should be the answer :slight_smile:apple
price: 2
stock: 0

error:
File "python", line 16
print "prices: %s" prices[key]
^
SyntaxError: invalid syntax


#2

Please make sure that copying the code in your post produces the same issue as you describe (try doing this and observe that it doesn't in this case)

Also note that you're printing something slightly different from what they describe should be printed


#3

Hi I dont really know what I am doing wrong so if you could direct me a
little bit that would be good

Thanks


#4

add '%' (without quotes) after " prices: %s" in line 16 and after "stock:%s" in line 17 . This should solve the problem .


#5

Sorry dont really understand what do you mean

or key in prices:
print "prices:%s" prices[key]
print "stock: %s" stock[key]


#6

just add % after the places i specified


#8

thanks a lot, but i stell have a problem

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

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

for key in prices:
print key
print "prices:%s" % prices[key]
print "stock: %s" % stock[key]

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


#9

U just need to add an empty space in line 16 . Check the description and your code for where you have to put it . I can't help more sorry . Just read rules and it is against them .


#10

The space after the colon is expected by the lesson checker.


#11

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