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


#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]

Why does it print out"Oops, try again. Check what your code prints for orange. It doesn't look quite right!"?


#2

Big question mark here. Please explain.


#3

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

also the same.


#5

Read again this part of instructions:

Print the answer in the following format:

apple
price: 2
stock: 0

And this is what your program prints out for orange:

orange
prices: 1.5
stock: 32

Do you see a problem?


#6

This is work for me:


for x in prices:

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



#7

WOW!! Sometimes in coding it could be just that one charachter that can turn your world upside down. This had me stumped for quite a while. Everything else was correct except for that one charachter. I suppose a coder's best developed quality should be attention to detail and the detail in instructions


#8

there's a space between "prices:" and "%s"


#9

One letter makes you go crazy!!!


#10
> for key in stock:
>         print key
>         print "Prices: %s" % prices[key]
>         print "Stock: %s" % stock[key]

still i getting the error how to solve this?


#11

change that to price

should work then


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

Now it worked.tnx :relaxed:


#14