Need help with 8/13 keeping track of the produce


Here 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[key]:
	print "price: %s" % prices[key]
	print "stock: %s" % stock[key]

it keeps saying unexpected indent and when i put it to no indent it says for [for key in prices] is not defined


Hi @cssmaster33154,

This indent may be what was unexpected …

 for key in prices[key]:

Compare it, in your post, to the preceding line.

You may also want to re-examine the content of the for loop header.


i fix the indent and now it says for in prices is not defined


You have included prices[key] in the for loop header. Should you be only considering one item within prices or might it be better to traverse the entire dictionary, which can be accessed within the header simply as prices?


@appylpye now it say i need three print statements


The instructions ask for some additional data that you have not provided in the output.

Consider displaying the value of key on its own line within the loop, prior to displaying the other data.


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