Input/Output to/from the console

  console, io, python, python-3.x

I am working on an application and there is a library code where it prompts the user by asking a question. The user then provides the answer in the console. The prompt and the user input are both captured using stderr. Since I cannot access the prompt from the console to the webpage, is there an easy way to perform these steps:

  1. Capture the prompt from the console inside a Python script
  2. Provide an input for the prompt from the same script as used in step 1
  3. Send the user input to the console again from the same script

Source: Python Questions