From db1497a74eb4338e4acd1921b365b567a830199b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=90=D0=B3?= =?UTF-8?q?=D0=BB=D1=8F=D0=BC=D0=BE=D0=B2?= Date: Wed, 27 May 2026 23:35:12 +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=20=D1=81=D0=BA=D1=80=D0=B8=D0=BF=D1=82=20=D0=BE=D0=B1?= =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA=D0=B8=20=D1=84=D0=B0=D0=B9?= =?UTF-8?q?=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data.txt | 5 +++++ main.py | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 data.txt create mode 100644 main.py diff --git a/data.txt b/data.txt new file mode 100644 index 0000000..7bc35e1 --- /dev/null +++ b/data.txt @@ -0,0 +1,5 @@ +banana +apple +orange +grape +lemon \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..fe1a869 --- /dev/null +++ b/main.py @@ -0,0 +1,22 @@ +# Открываем входной файл data.txt для чтения +with open("data.txt", "r", encoding="utf-8") as file: + lines = file.readlines() + +# Убираем лишние пробелы и переносы строк +cleaned_lines = [line.strip() for line in lines] + +# Удаляем пустые строки +cleaned_lines = [line for line in cleaned_lines if line] + +# Сортируем строки по алфавиту +sorted_lines = sorted(cleaned_lines) + +# Переводим строки в верхний регистр +upper_lines = [line.upper() for line in sorted_lines] + +# Записываем результат в файл output.txt +with open("output.txt", "w", encoding="utf-8") as file: + for line in upper_lines: + file.write(line + "\n") + +print("Файл output.txt успешно создан.") \ No newline at end of file