0

Is there a way to respond to an input using a code other than putting your answer directly into the terminal?

Like, for example... Is it possible to respond to this code by writing another code?

time = input ("when do you want to set the alarm?")
#then the code for my answer:

or can I only respond by typing at the terminal below?

>>> when do you want to set the alarm?

Bob
  • 43
  • 6
  • 1
    No, not in the same thread of course, the thread is waiting for an input. You can use another process and attach it to the input, e.g. `python yourapplication.py < \`python yourinputapplication.py\``, and if that garbles up your I/O, see [here](https://stackoverflow.com/questions/34366763/input-redirection-with-python) – Maarten Bodewes Apr 22 '22 at 00:29
  • ... or `python yourinputapplication.py | python yourapplication.py`. might be better. – Maarten Bodewes Apr 22 '22 at 00:35

0 Answers0