Keeping track of the produce


#1

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]
and it says Oops, try again. Check what your code prints for orange. It doesn't look quite right!
and this what is printed in console:
orange
prices:1.5
stock:32
pear
prices:3
stock:15
banana
prices:4
stock:6
apple
prices:2
stock:0
None
this means orange is printed right why oOPS


#2

If we look at the example on the left of the lesson, we see it reads, price:.


#3

what do you mean by that please dude explain more


#4

Take out the s in prices and write print "price: %s"


#5

orange
Traceback (most recent call last):
File "python", line 15, in
NameError: name 'price' is not defined
he said that when i took the s


#6

and when i only deleted the s in "price: %s" to be like this it says the same problem


#7

Make sure that your variable is still named prices. Only the printed text needs to read, price.


#8

Uploading... and this the video about the main problem please see it its short


#9

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

#10

i did that and it has the exact same error


#11

Will need to see your code, again, please, and also a link to the exercise so I can test it. Thanks.


#12

https://www.codecademy.com/courses/python-beginner-en-IZ9Ra/1/3

this is the link
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 key
        print "price:%s" % prices[key]
        print "stock:%s" % stock[key]

#13

The exact problem is going to make you growl...

"price: %s"
"stock: %s"
       ^
     space

#14

thanks alot it helped and i understand


#15

A post was split to a new topic: Can't find the error


#17