I have a function that prints text to the console. Below is a version of what the code looks like (it's actually a lot of lines of a story, so I'm summarizing it.) My question is - is there another function I can write to take all_text() and generate a docx file with the it? I've managed to create a .txt file, but I would ideally like to create something with formatting options.
from docx import Document
document = Document()
def all_text():
print("Line1\nLine2\nLine3")
document.add_paragraph(all_text())
document.save("demo.docx")