How can I input some commands into terminal in Swift like this?

that is my python code (file name pythonTest.py)

while True:
   a = input()
   print(a)

I want to run this python code in a swift script and get the result.

For example, I would like to enter something command like this.

python3 pythonTest.py\n1\n2\n3\n and ctrl + C

i found Process() but this is only entered once and I don't know how to handle input(), ctrl + C

How can I do that?

If it's not possible in Swift, is it possible in Python?

How can I input some commands into terminal in Swift like this?
 
 
Q