/
RecentFellowKid
/
Opening_and_Reading
Обзор
Документация
Войти
/
RecentFellowKid
/
Opening_and_Reading
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
first_task.py
31 строка
972 B
RecentFellowKid
Initial commit
11 авг 2025, 03:53
11 авг 2025, 03:53
2abaeab
Код
Авторство
О чём код?
def load_cook_book_from_file(): cook_book = {} with open('recipes.txt', 'r', encoding='utf-8') as file: while True: dish_name = file.readline().strip() if not dish_name: break ingredients_count = int(file.readline().strip()) ingredients = [] for _ in range(ingredients_count): ingredient_data = file.readline().strip().split('|') ingredient_name = ingredient_data[0].strip() quantity = int(ingredient_data[1].strip()) measure = ingredient_data[2].strip() ingredients.append({ 'ingredient_name': ingredient_name, 'quantity': quantity, 'measure': measure }) cook_book[dish_name] = ingredients file.readline() return cook_book if __name__ == "__main__": print(load_cook_book_from_file())