Mecha Munch Management : Task 5 : Try to understand the output error

Hi,
I have a question about the Task 5 output error. I did my following program on my IDE which it gives me a similar output on the solution examples. However the corrector tells me that I have an error even if I got the same output as it has. If it’s an error in my program or a modification to do I am down to discuss about it :).

You mean the linter, pylint? What does it tell you? It’s hard to discuss a error (or warning) without seeing it.

Please use codeblocks and not images to share text!

Yes the pylint. It gives me assertion errors which are the following :

AssertionError: Order[36 chars]lse]), (‘Milk’, [‘Aisle 2’, True]), (‘Banana’,[48 chars]e])]) != Order[36 chars]lse])]) : Called send_to_store({‘Orange’: 1}, {‘Banana’: [‘Aisle 5’, False], ‘Apple’: [‘Aisle 4’, False], ‘Orange’: [1, ‘Aisle 4’, False], ‘Milk’: [‘Aisle 2’, True]}). The function returned {‘Orange’: [1, ‘Aisle 4’, False], ‘Milk’: [‘Aisle 2’, True], ‘Banana’: [‘Aisle 5’, False], ‘Apple’: [‘Aisle 4’, False]}, but the tests expected: {‘Orange’: [1, ‘Aisle 4’, False]} as the fulfillment cart.

Or this one :

AssertionError: Order[40 chars]), (‘Milk’, [‘Aisle 2’, True]), (‘Banana’, [3,[50 chars]e])]) != Order[40 chars]), (‘Banana’, [3, ‘Aisle 5’, False]), (‘Apple’[21 chars]e])]) : Called send_to_store({‘Banana’: 3, ‘Apple’: 2, ‘Orange’: 1}, {‘Banana’: [3, ‘Aisle 5’, False], ‘Apple’: [2, ‘Aisle 4’, False], ‘Orange’: [1, ‘Aisle 4’, False], ‘Milk’: [‘Aisle 2’, True]}). The function returned {‘Orange’: [1, ‘Aisle 4’, False], ‘Milk’: [‘Aisle 2’, True], ‘Banana’: [3, ‘Aisle 5’, False], ‘Apple’: [2, ‘Aisle 4’, False]}, but the tests expected: {‘Orange’: [1, ‘Aisle 4’, False], ‘Banana’: [3, ‘Aisle 5’, False], ‘Apple’: [2, ‘Aisle 4’, False]} as the fulfillment cart.

The code you shared shows you’re not using the count/numbers from the cart. That value needs to be used in your solution.

I see what you mean now, but am I not using already the number of the item from the cart with cart[item] in the insert, which is implemented in the aisle_mapping dictionary as a value in the list ?

Ah. Yes. You’re right. I misread that.

If I call this, which items are in the returned dictionary?

send_to_store({"apple": 2, "banana": 3}, {"banana": ..., "cherry": ...})

Theoretically only the item banana would return the value 3 on the aisle_mapping dictionary if I am not mistaken.

Do you think that the error is caused by the lack of an else condition if the item is not in the cart and/or not in the aisle_mapping ?

Isn’t there cherry in that dict? Where/when does that get removed?

Ah now I see, we want that cherry stays in the dictionary and doesn’t get removed when we call the condition. Hence now I think that my mistake comes from the insert condition. Ill grab a look and change a bit my program.

Thank you :)