From 982f23dd9767c6c255174485fdff2a14846e8a58 Mon Sep 17 00:00:00 2001 From: "baranovacate14@gmail.com" <baranovacate14@gmail.com> Date: Wed, 22 Nov 2023 20:06:00 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B8=D0=B7=D0=B1=D0=B0=D0=B2=D0=BB=D1=8F?= =?UTF-8?q?=D0=B5=D0=BC=D1=81=D1=8F=20=D0=BE=D1=82=20=D0=BB=D0=B8=D1=88?= =?UTF-8?q?=D0=BD=D0=B8=D1=85=20=D0=BF=D1=80=D0=BE=D0=B1=D0=B5=D0=BB=D0=BE?= =?UTF-8?q?=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- remove_space_file.py | 17 +++++++++++++++++ remove_space_str.py | 10 ++++++++++ text.txt | 0 3 files changed, 27 insertions(+) create mode 100644 remove_space_file.py create mode 100644 remove_space_str.py create mode 100644 text.txt diff --git a/remove_space_file.py b/remove_space_file.py new file mode 100644 index 0000000..65f6f7b --- /dev/null +++ b/remove_space_file.py @@ -0,0 +1,17 @@ +def remove_spaces_file(file)->list: + f = open(file) + text_0 = f.readlines() + string = "" + for line in text_0: + string = string + line + word = string.split(" ") + w = str() + for i in word: + if i != "": + w += i + " " + list(w) + return w + +text ='text.txt' +text =remove_spaces_file(text) +print(text) diff --git a/remove_space_str.py b/remove_space_str.py new file mode 100644 index 0000000..70e39c7 --- /dev/null +++ b/remove_space_str.py @@ -0,0 +1,10 @@ +def remove_space(stroka:str)->str: + word = stroka.split(" ") + w = str() + for i in word: + if i != "": + w += i+" " + return w + +stroka_0 = "hello word " +print(remove_space(stroka_0)) diff --git a/text.txt b/text.txt new file mode 100644 index 0000000..e69de29 -- GitLab