From 0cc09de42eb587f112285d06541294b379973039 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95=D0=BB=D0=B8=D0=B7=D0=B0=D0=B2=D0=B5=D1=82=D0=B0=20?= =?UTF-8?q?=D0=A1=D1=8E=D0=B7=D0=B5=D0=B2=D0=B0?= Date: Thu, 6 Mar 2025 19:36:01 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20data.txt=20?= =?UTF-8?q?=D0=B8=20script.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data.txt | 5 +++++ script.py | 13 +++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 data.txt create mode 100644 script.py diff --git a/data.txt b/data.txt new file mode 100644 index 0000000..b6c26bd --- /dev/null +++ b/data.txt @@ -0,0 +1,5 @@ +Бананы +Творог +Йогурт +Вишня +Чай \ No newline at end of file diff --git a/script.py b/script.py new file mode 100644 index 0000000..ecc4cea --- /dev/null +++ b/script.py @@ -0,0 +1,13 @@ +# Открываем data.txt и читаем содержимое +with open("data.txt", "r", encoding="utf-8") as file: + lines = file.readlines() + +# Преобразуем данные: переводим в верхний регистр и сортируем +processed_lines = sorted(line.strip().upper() for line in lines) + +# Записываем результат в output.txt +with open("output.txt", "w", encoding="utf-8") as file: + for line in processed_lines: + file.write(line + "\n") + +print("Файл output.txt успешно создан!")