Cannot understand where the mistake is


#1

Hey guys,

I hope everyone is doing great.

I am stuck on the 'keeping track of the produce' task. Here 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 key
    print 'Price: %s' % prices[key]
    print 'Stock: %s' % stock[key]

And below you can see my output:

orange
Price: 1.5
Stock: 32
pear
Price: 3
Stock: 15
banana
Price: 4
Stock: 6
apple
Price: 2
Stock: 0

Everything looks correct to me but the program keeps saying 'Check what your code prints for orange. It doesn't look quite right!'. The prices and quantities seem to be correct. What am I doing wrong here?

Thanks in advance for the help.


#2

Never mind, I got it to work!


#3

me too ! i don`t know how to meke it right


#4

Can you explain how you were able to fix this error? I am getting the same one.
Thanks!


#5

try %d instead of %s. For int instead of str.


#6

Thank you! Unfortunately, it still is not working. The same error comes up...


#7

Maybe you shouldn't capitalize "Price" (should be "price") and "Stock"(should be "stock") like it is in the directions. That might be the problem.


#8

ok i had the same problem, the solution is simple
Simpy change the capital P an S in to small p and s in Price and Stock
print 'Price: %s' % prices[key]
print 'Stock: %s' % stock[key]