8. Keeping Track of the Produce. Suspicious question for you all


First off I'm very very glad this site exists, and thank you to the creators, but leading up to this lesson I've run into two or three points where I was just stumped as to how to do some things they ask you to do.

Here's the code showing the most recent moment where I was stumped.

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  # <------- This line of code right here***
    print "price: %s" % prices[key]
    print "stock: %s" % stock[key]

This was another point where I was stumped, because the instructions ask you to print only the name of the keyword above "price" and "stock". When I hit this point I thought to myself... Did they ever tell us how to do this? And when I looked up the solution it made me think about other lessons that made me ask the same question. Did anyone know you could do this beforehand before you solved it, or did I just missed the part that said. "You can print only the name of the key by typing this."

Anyone else ever suspect this or am I crazy?

Anyway, my first time asking a question here. I've been trying to learn how to code, off and on, ever since high school , always driven by a desire to make a video game. First language I tried to learn was C++. I remember reading these enormous books and feeling that none of the authors were very good at explaining things for beginners to understand, Always felt like all these little details were missing. All my experiences coding could be summed up like this: try to learn, give up, try again, give up, over and over. I figure I must really want to learn if I keep on trying. But, I've never learned from a site like this before, so my hopes are high. I chose to learn python because the game making software i'm using was built with it, and in order to really customize your game you just need to know python... seems like there's no way around it, so here I am, trying to learn code again. Anyway It's super late and I'm making typos, so I should probably sleep.


from the instructions:

Loop through each key in prices.
Like the example above, for each key, print out the key (1) along with its price (2) and stock (3) information

i added numbers, the exercise clearly asks for 3 prints.

this should be taught in 9. list and dictionary's track

Of course you sometimes need to learn new things, but how to print the iterator (in this case key) has most certainly been taught.

Programming is very difficult. It has up and downs, and to understand it takes a lot of time and practice


Thanks for the reply. For the most part though these lessons have been clear and effective, to the point where last night I looked back at some code I didn't understand with my game making software, and the structure of it seemed more familiar to me than it did even a week ago. So, all in all this has been great.

I'll be going through all of these lessons again once i finish.


once you are done on codecademy i recommend sololearn, i think it is an excellent to do after codecademy try to take the shortcut for the first section.

Good that it starts to make more sense, that is a good first step


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