A Day at the Supermarket error


#1

https://www.codecademy.com/courses/python-beginner-en-IZ9Ra/1/3?curriculum_id=4f89dab3d788890003000096

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

Here's my output...

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

I think I have the right output, but I can't move to the next assignment due to that error? Any suggestions?


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]


#2

Hi these lines

    print "Price: %s" % prices[key]
    print "Stock: %s" % stock[key]

these part

    print "Price: %s" ..
    print "Stock: %s"...

you should change the P and S with the downcase p and s


#3

Why did the uppercase cause an error


#4

Because they want you to print

orange
price: 1.5
stock: 32

which is different of

orange
Price: 1.5
Stock: 32

that's why you got an error


#5

u get eh error without the uppercase also

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]

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


#6

i cant find teh issue?


#7

Hi this line

print "prices: %s"% prices[key]

this part

"prices: %s"

remove the s to price


#8

Sorry for the late reply everyone. It was simply the capital letters. Doh!


#9

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