/
NataliaS
/
read_files
Обзор
Документация
Войти
/
NataliaS
/
read_files
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
task2.py
23 строки
765 B
Nataly Semynina
Initial commit
22 ноя 2025, 12:55
22 ноя 2025, 12:55
a8b0999
Код
Авторство
О чём код?
from load_recipes import load_recipes cook_book = load_recipes("recipes.txt") print(cook_book) def get_shop_list_by_dishes(dishes, person_count): shop_list = {} for dish in dishes: for ingredient in cook_book[dish]: quantity = ingredient['quantity'] * person_count name = ingredient['ingredient_name'] if name in shop_list: shop_list[name]['quantity'] += quantity else: new_ingredient = { 'measure': ingredient['measure'], 'quantity': quantity } shop_list[name] = new_ingredient return shop_list print(get_shop_list_by_dishes(['Запеченный картофель', 'Омлет'], 2))