diff --git a/script.py b/script.py index bb1f717..a87b731 100644 --- a/script.py +++ b/script.py @@ -1,24 +1,5 @@ -with open("data.txt", "r", encoding="utf-8") as file: - lines = file.readlines() +with open("data.txt", "r", encoding="utf-8") as infile: + lines = infile.readlines() -numbers = [] -words = [] - -for line in lines: - line = line.strip() - if line.isdigit(): - numbers.append(line) - else: - words.append(line) - - -with open("output.txt", "w", encoding="utf-8") as output_file: - output_file.write("Слова:\n") - for word in words: - output_file.write(word + "\n") - - output_file.write("\nЧисла:\n") - for number in numbers: - output_file.write(number + "\n") - -print("Файл output.txt успешно создан!") +with open ("output.txt" ,"w" encoding="utf-8" as outfile: + outfile.writelines(transformed_data)