Something wrong with orange


#1

Can you help me find what is wrong with orange?

The example is:

apple
price: 2
stock: 0

and my code outputs:

orange
price: 1.5
stock: 32
pear
price: 3
stock: 15
banana
price: 4
stock: 6
apple
price: 2
stock: 0
None


#2

The output is okay to understand your problem, but please share your code my friend! (:


#3

for o in prices:
    print o
    print 'price:', prices[o]
    print 'stock:', stock[o]

#4

anyone ever figure this out, I have the same output/error

Here's the code"

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 "Price: %s" % prices[key]
print "Stock: %s" % stock[key]

#5

Capitalization is important


#6

I found a way to make it work.

The exercise requires use of % even though it is only a suggestion in the instructions.

i.e. This must be used:

print 'price: %s' % price

instead of

print 'price:', price

even though their outputs are the same.


#7

4 posts were split to a new topic: Sth is wrong with my orange but don't know why


#14