diff --git a/.gitignore b/.gitignore index 21d0b89..c136cf9 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .venv/ +output.txt \ No newline at end of file diff --git a/data.txt b/data.txt new file mode 100644 index 0000000..3f1cc63 --- /dev/null +++ b/data.txt @@ -0,0 +1,3 @@ +машина +дом +спать \ No newline at end of file diff --git a/script.py b/script.py new file mode 100644 index 0000000..971a815 --- /dev/null +++ b/script.py @@ -0,0 +1,15 @@ +# Открываем файл data.txt для чтения +with open('data.txt', 'r', encoding='utf-8') as file: + # Считываем все строки из файла + lines = file.readlines() + +# Преобразуем данные: переводим все строки в верхний регистр и сортируем +transformed_lines = [line.strip().upper() for line in lines] +transformed_lines.sort() + +# Записываем преобразованные данные в файл output.txt +with open('output.txt', 'w', encoding='utf-8') as file: + for line in transformed_lines: + file.write(line + '\n') + +print("Данные успешно обработаны и записаны в output.txt") \ No newline at end of file