How to create a document generator?

Hello everyone.

I’m learning to code using Python, so i recently started a few courses and im a little bit lost in this:

Can i make a document generator using python? I want to put it in a webpage so the people answer some questions and put those in a template recently created.

First i tought about making a program with some if, else and input things, but the main idea is to make this tool accessible form the web, so im affraid that python isnt the best language for doing so… maybe PHP, so i wanted to ask you guys for some advice.

If its possible to do that, where should i start? Besides, of course, making my template and my program.

I was looking this video and helped me a little bit: https://www.youtube.com/watch?v=ZDR7-iSuwkQ, but i dont want to make the pdf myself, instead i want to make a prompt that asks the user some data and store it in some places of a template, so when the user is done the program creates a document filled with the data that the user entered.