A day at supermarket


#1



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]

"""what is wrong with my code"""


#2

the product has a price: , not prices:


#3

is price predefined somewhere please tell me the reason


#4

no, price: is just a string. the output needs to be an exact match


#5

thank u yes i didnt notice


#6

A post was split to a new topic: A day at supermarket


#7

That does't make sense could you explain more. It's just a string so I should be able to name whatever I want and it should still work?


#8

What is price matching that prices doesn't. Price is not listed anywhere

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 "stocks: %s" % stock[key]


#9

here:

print "prices:

prices is a string, but the output needs to be an exact match, so it should "price: and "stock:


#10

"orange":15
make the float value into an integer


#11

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