You're cooking a few dishes this weekend, and each recipe is {ingredient: how many}. Write shopping_list(recipes): add up each ingredient across the recipes, sort by ingredient name, write each one like 'egg x5', and return the list.
shopping_list([{"egg": 2, "flour": 1}, {"egg": 3, "milk": 1}])→['egg x5', 'flour x1', 'milk x1']shopping_list([])→[]def shopping_list(recipes):
need = {}
# your code here: for each recipe and each ingredient, add the amount into need
# your code here: sort by name and, in one line, return the list of 'name xN'
return []
Run tries the examples. When they look right, Submit.