Keeping track of the produce!


Oops, try again. You should have exactly three print statements! (Make sure there are no occurrences of 'print' in any comment or string!)

I did it first without the last print comment and the same error pop'd up so I later thought it wanted me to have each fruit item (with its prices and stock #) separated from the other fruits but it still didn't work. It had the same error.

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]


Hi @jac52792,

Remove this comment entirely ...



doesn't the hashtag null the print??
anyways the same error is popping up.


The # does denote a comment, and therefore the print on that line does not execute. However, Codecademy's submission correctness test (SCT) for this exercise counts all of the occurrences of print within the submitted code, including any that occur within a comment. That count must be exactly 3. You have 4 occurrences.


I got it, you had me at SCT. I had my failed attempts of code also denoted by the '''.....'''.

The fourth print at the end does make it neater in that it separates all the fruits with their price and stock#. But I feel like there could be a better way in separating the keys instead of putting a print at the end or am I smoking???


By inserting a \n, this statement would leave a blank line after all the information for each food item is displayed, but the SCT does not like it either ...

print "stock: %s\n" % (stock[key])

There's nothing inherently wrong with doing it that way; the issue is merely that the SCT considers it to not conform to the exercise specifications.

EDITED (January 22, 2017) to add the following solution to the problem ...

If you replace this ...

print 'stock: %s' % stock[key]

... with this ...

print 'stock: %s' % (stock[key]), '\n'

... the SCT is satisfied, and you get the blank line you are seeking.


looks much much neater. If I got any q's I hope I get your responses