forked from stud179274/Practice
Добавлены файлы data.txt, script.py
This commit is contained in:
parent
270374ecdf
commit
a6999dfe76
1
Часть 3/.gitignore
vendored
Normal file
1
Часть 3/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
output.txt
|
5
Часть 3/data.txt
Normal file
5
Часть 3/data.txt
Normal file
@ -0,0 +1,5 @@
|
||||
Бананы
|
||||
Творог
|
||||
Йогурт
|
||||
Вишня
|
||||
Чай
|
13
Часть 3/script.py
Normal file
13
Часть 3/script.py
Normal file
@ -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 успешно создан!")
|
Loading…
Reference in New Issue
Block a user