Problem in lesson 10- a day at the 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 "prices of inventory %s" %prices[key]
print "quantity of inventory %s" %stock[key]

how to get the ouput in following style
apple
price: 2
stock: 0


#2

You need to print "price" and "stock"


#3

you wanna like this ??

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

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

#4

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


#5

there is bug in this section. how to move forward as code is running properly in python


#6

got it right

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

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


#7

It's not bug your code is not working properly. What's your second loop doing?


#8

i think this code work for me

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

#9

это мой код, и печатается последовательностью orange-pear-banana-apple. я не знаю почему
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]


#10

you ■■■■■■■ wizard! Why when I print my code(for key in prices:
print key
print "prices: %s" % prices[key]
print "stock: %s" % stock[key]) nothing has worked, but when I print Your code, which is identical to my, all is worked! no comments


#11

it's f u c k i n g 'S' at the end of "prices". it shouldn't be!