diff --git a/.gitignore b/.gitignore index 0cafc1c..c136cf9 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.venv/ \ No newline at end of file +.venv/ +output.txt \ No newline at end of file diff --git a/README.md b/README.md index e533d4c..3c2f9d2 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ -Задание по Python \ No newline at end of file +Задание по Python + +Прочитать файл data.txt, поменять регистр букв и записать рещультат в output.txt diff --git a/data.txt b/data.txt new file mode 100644 index 0000000..ae05791 --- /dev/null +++ b/data.txt @@ -0,0 +1,2 @@ +Hello World +Hello Sailor \ No newline at end of file diff --git a/script.py b/script.py new file mode 100644 index 0000000..5a90bc1 --- /dev/null +++ b/script.py @@ -0,0 +1,16 @@ +def convert_case(text): + return text.swapcase() + +def main(): + with open('data.txt', 'r') as file: + data = file.read() + + converted_data = convert_case(data) + + with open('output.txt', 'w') as file: + file.write(converted_data) + + print("Регистр букв изменён. Результат записан в output.txt") + +if __name__ == "__main__": + main() \ No newline at end of file