Script.py - printing Dictonaries - ORANGE


#1




Code behaves correctly however I think my code is being checked in the backround for printing accuracy this where I am getting frustrated, my code correctly prints "Orange Quantity available and Price, but I keep getting following error msg
"Oops, try again. Check what your code prints for orange. It doesn't look quite right!"

Go figure oranges..lol

I expect my code academy to say my code was executed successfully and move to next lesson.


prices = {
    "banana": 4,
    "apple": 2,
    "orange": 1.5,
    "pear": 3
    }
    
stock = {
    "banana": 6,
    "apple": 0,
    "orange": 32,
    "pear": 15
    }

for Keys in stock:
    print Keys
    print stock[Keys]
    print prices[Keys]


#2

this is the desired output:

apple
price: 2
stock: 0

your could would output:

apple
2
0

not a good match


#3

I am experiencing the same problem with orange.
This is my 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 "%s " %key
print "price: %s" % prices[key]
print "stock: %s" % stock[key]


#4

the validation for this exercise is really strict, on line 4 you have a space after %s, remove it, it causes the error


#5

Thanks. It works now :slight_smile:


#6

prices = {
"banana":4,
"apple":2,
"Orange":1.5,
"pear":3
}
stock = {
"banana":6,
"apple":0,
"Orange":32,
"pear":15
}
for key in prices:
print "%s" %key
print "Prices: %s" % prices[key]
print "Stock: %s" % stock[key]

I am experiencing the same problem with orange.


#7

Prices should be price, and Stock should be stock.

the exercise is really strict, like i said (to the letter, and case sensitive)


#8

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