Write a function that multiplies each dictionary value by portions portions = 5 grams = 0 key = 'salad' cook_book = {'salad': [{'ingridient_name': 'cheese', 'quantity': 50, 'measure': 'gr'}, {'ingridient_name': 'tomatoes', 'quantity': 2, 'measure': 'pct'}, {'ingridient_name': 'pepper', 'quantity': 20, 'measure': 'гр'}]} if key == 'salad': grams = 'quantity' * portions print(grams)
def cook_book(): portions = 5 for key, value in cook_book.items(): for sub_dict in value: for v in sub_dict.values(): ingridient_name = v[0] quantity = v[1] measure = v[2] grams = quantity * portions print(grams) return grams