Error in output


#1



Keeping track of the produce


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


accepting the code without errors


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

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


#2

look at your spacing around %s there should be one space before and none after


#3

I removed the extra space but still the code shows an error.
The error is
"Check what your code prints for orange. It doesn't look quite right!"


#4

can i see an updated version of your code?


#5

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]


#6

Does the example output (which you need to duplicate) capitalized letters in Price and Stock?


#7

yes. I am pasting the example output below
once = {'a': 1, 'b': 2}
twice = {'a': 2, 'b': 4}
for key in once:
print "Once: %s" % once[key]
print "Twice: %s" % twice[key]


#8

but in the instructions is the example of your output should look:

Like the example above, for each key, print out the key along with its price and stock information. Print the answer in the following format:

apple
price: 2
stock: 0

the information you refer to is only a syntax refresher.


#9

Got it, Corrected the code now Changed the case of Price and Stock and the code executed with out any errors.Thank you for the time and help.


#10