/
yagario
/
Task1
Обзор
Документация
Войти
/
yagario
/
Task1
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Task1.py
25 строк
899 B
yagario
Загрузка задания
04 июл 2025, 12:31
04 июл 2025, 12:31
09027fe
Код
Авторство
О чём код?
def read_cook_book(filename): cook_book = {} with open(filename, 'r', encoding='utf-8') as file: while True: dish_name = file.readline().strip() if not dish_name: break ingredients_count = int(file.readline()) ingredients = [] for _ in range(ingredients_count): ingredient_line = file.readline().strip() name, quantity, measure = [x.strip() for x in ingredient_line.split('|')] ingredients.append({ 'ingredient_name': name, 'quantity': int(quantity), 'measure': measure }) cook_book[dish_name] = ingredients file.readline() return cook_book cook_book = read_cook_book('recipes.txt') from pprint import pprint pprint(cook_book)