8/13 Out of Ideas


#1

I searched for a half our now on this subject, but none of the answers worked for me.
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]

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


#2

yeah me too. i have the same code and same error.


#3

getting same error. I don't know what is wrong with oranges


#4

prices and stocks should not have capital letters


#5

copy and paste below it works

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]
#p is small in price.
#s is small in stock.


#6

prices = {
'banana':4,

}

stock = {
'banana': 6,

    }

for key in prices:
print key
print "price: %s" % prices[key]
print "stock: %s" % stock[key]

This is certinly not the correct code,but with this i got to pass to the next task .
I think there is just an error in the task.


#7

had a trouble too. Use my code to pass it:

price = {

"apple": 2,

}

stock = {

"apple": 0,

}

for key in prices:
print key
print "price: %s" % price[key]
print "stock: %s" % stock[key]


#8

I've figured it out. It doesn't work because the program rounds down the 1.5 for oranges in its output, and codecademy checks that the number in the code and the number in the output are the same. Therefore, the rounded down number is different from the regular number in the code. It does this because it's a decimal. All you need to do to pass this unit is to set the value of oranges to a whole number, which allows codecademy to correctly compare the number in the code with the number in the output, passing the unit. I hope this helps.


#9

The error is a stupid one but python doesn't like it when you call "prices" when it asks for price. This code works:

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]


#10

yeah, I sorted that out on that same day. anyway thanks for help.


#11

for amount in prices:
print amount
print "price: %s" % prices[amount]
print "stock: %s" % stock[amount]

You'll have to indent it but this should work


#12

Tnx for all the answers guys!


#13

This helped a lot! Thank you


#14

the last three lines are indented


#15
for key in prices:
    print key
    print "price: %s" % prices[key]
    print "stock: %s" % stock[key]

#16

Yeah I had the same problem - using lower case letters throughout the print statements worked for me - thanks


#17

SOLUTION

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]

MOVE THIS "PRINT" TO THE RIGHT AND IT WILL WORK!