проверил, что не добавляется output.txt

This commit is contained in:
Кирилл Тюрнин 2025-03-04 21:59:04 +03:00
parent 9d1fcca8e9
commit 27e3dcfcfe
3 changed files with 20 additions and 1 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
.venv/
output.txt

6
data.txt Normal file
View File

@ -0,0 +1,6 @@
сосиски
молоко
майонез
огурцы
помидоры
хлеб

12
script.py Normal file
View File

@ -0,0 +1,12 @@
# script.py
with open('data.txt', 'r', encoding='utf-8') as file:
lines = file.readlines()
uppercase_lines = [line.strip().upper() for line in lines]
with open('output.txt', 'w', encoding='utf-8') as output_file:
for line in uppercase_lines:
output_file.write(line + '\n')
print("Данные успешно записаны в output.txt")