About task3 in Mecha Munch Management, the 1st Dict Methods exercise in python

It’s about Merging or Updating Dictionaries
In task 3. Update Recipe “Ideas” Section
When you code like below, you pass the test

=============================

def update_recipes(ideas, recipe_updates):
"""Update the recipe ideas dictionary.

:param ideas: dict - The "recipe ideas" dict.
:param recipe_updates: *dict* - dictionary with updates for the ideas section.
**->I think it should be changed, because a tuple or a list of key-value pairs, not a dict, is used in the example and the test data.**
:return: dict - updated "recipe ideas" dict.
"""

ideas.update(recipe_updates)
return ideas

==========================
but in the example, below

> update_recipes({'Banana Bread' : {'Banana': 1, 'Apple': 1, 'Walnuts': 1, 'Flour': 1, 'Eggs': 2, 'Butter': 1},
                  'Raspberry Pie' : {'Raspberry': 1, 'Orange': 1, 'Pie Crust': 1, 'Cream Custard': 1}},
(('Banana Bread', {'Banana': 4,  'Walnuts': 2, 'Flour': 1, 'Butter': 1, 'Milk': 2, 'Eggs': 3}),))
...
#the result is

>>{'Banana Bread' : {'Banana': 4,  **'Apple': 1**, 'Walnuts': 2, 'Flour': 1, 'Butter': 1, 'Milk': 2, 'Eggs': 3},
 'Raspberry Pie' : {'Raspberry': 1, 'Orange': 1, 'Pie Crust': 1, 'Cream Custard': 1}}

‘Apple’:1 is still in the result.

But in update method, when keys in the two dictionaries overlap , the value in dict_one should be overwritten by the corresponding value from dict_two, not appended.

I wonder if the answers or this example shoude be changed.

Hi @nonameg11 :wave:

Yes – that should be flagged as a tuple in the doctstring, and the examples should also be adjusted. Thanks for reporting those. :smile:

I’ll put this in with the other change, and let you know when the site is updated.

Edited to add fixed in [Mecha Munch Management] Fixed typos in Instructions, Introduction, & Stub File by BethanyG · Pull Request #3937 · exercism/python · GitHub, and will be merged as soon as CI clears. :smile:

1 Like