Keeping track of the produce


can't figure out what is wrong, even changed somethings looking at some examples on the forum but no luck. what is wrong? please help.

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]

can not get the indent right here on the forum = /


Compare what you print to the format shown in the instructions


In your print statement for you have Price(s) instead of just Price. Not sure if that is causing the error, seemed to make my code not work


it is the same format, the only thing that is on a dif format are the dictionaries, which I did on another exercise (just like the example) and where dragged down to this exercise


It isn't. Here's where you need to start looking for the smallest little details. It needs to be exactly the same.
There isn't very much text, this is very much something you can do just by eye.

Being able to find differences is a required skill for a programmer.

It's really just a matter of doing it in a methodical way which guarantees that any difference will be find.
You have a huge advantage in that I've already confirmed that there is a difference.

The way I go about finding differences if I can't see them myself (could be a very large file for example)
Is to copy each version into their own text files and running diff on them. diff is a program that comes with just about any linux distribution, you might not have that but you can get something equivalent, for example there are probably websites that do the same thing.


for key in once:
print "Once: %s" % once[key]
print "Twice: %s" % twice[key]

how is that different???
the first part was already done in another exercise and if I reset the code it shows up, so it has to be with this part of the code that something is wrong, but it's the same. so how is it different?


That's not the format from the instructions, that's from the "flavour text"

There's a part of the instructions which explicitly says: Print the answer in the following format:
And then follows the format.

So in addition to seeing details, there is the ability to read instructions and do exactly as they say.

That may sound condescending, but it's exactly what you're missing and I'm simply telling you so, allowing you to improve.

And "being able to read instructions" isn't as simple as it sounds.
But, it's something that you need to be really good at!

I could just point out the difference, but that's of little value. You gotta find what's making you not find it yourself, that's far more valuable.


thank you. i had to make Prices and Stock to price and stock. but the thing here is that the compiler wants price and stock, but the code should've still work and writing each code on it's own on python should work.


It was looking for an exact match, nothing else would do.

And while frustrating and disrupting.. It's something you need, so it's not a waste of time, pretty good spot to get stuck at actually.

People like to joke that programmer's minds are a bit damaged, well, it's stuff like this that requires us to think a bit differently.


Also, the compiler doesn't want much.

Python barely gets compiled at all, it's generally thought of as an interpreted language. The interpreter reads the code and executes it. A compiled language is compiled into machine code, readable by the CPU. In a way, the CPU is an interpreter so really everything is both compiled and interpreted in some sense.

The interpreter doesn't want a whole lot either. It just runs your code.

Your code is checked by some Python code that simply runs after yours:

    if not (CC.printed(key) and CC.printed("price: " + str(prices[key])) and CC.printed("stock: " + str(stock[key])) ):
        return "Check what your code prints for " + key + ". It doesn't look quite right!"

That's rather crude actually. (will allow some incorrect stuff to pass) Seems to work well enough though.