diff --git a/data.txt b/data.txt new file mode 100644 index 0000000..40e5d2d --- /dev/null +++ b/data.txt @@ -0,0 +1,3 @@ +Хлеб молоко яблоки + перец огурец ананас + лапша сосиски diff --git a/script.py b/script.py new file mode 100644 index 0000000..bb1f717 --- /dev/null +++ b/script.py @@ -0,0 +1,24 @@ +with open("data.txt", "r", encoding="utf-8") as file: + lines = file.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 успешно создан!")