0

I want to make my input continue after a new line is created in the terminal.

Here's the quick script I wrote:

import threading, time

def inn():
    while True:
        input()

def count():
    a=0
    while True:
        a+=1
        print(a)
        time.sleep(1)

t1 = threading.Thread(target=inn)
t2 = threading.Thread(target=count)

t1.start()
t2.start()

Is there any way I could accomplish this, preferably with in-built functions.

Hextav
  • 5
  • 5
  • What do you mean by input continue? a) one input reads multiple lines or b) multiple inputs read multiple lines and the inputs are concatenated? If you mean a) shells can do stuff like that already Does this help: https://stackoverflow.com/questions/30239092/how-to-get-multiline-input-from-user – Natan Apr 08 '22 at 20:58
  • I would like the program to continue allowing input after a new line is created. – Hextav Apr 08 '22 at 21:00
  • 1
    Does this answer your question? [How to read multiple lines of raw input?](https://stackoverflow.com/questions/11664443/how-to-read-multiple-lines-of-raw-input) – Natan Apr 08 '22 at 21:00
  • @natan, from what I understand this is not what I want to do. I'm using multithreading to have an input and print messages at the same time but when I try typing it just cuts off the input. – Hextav Apr 08 '22 at 21:19

1 Answers1

0

if you change your code to:

.
def inn(): # in is restricted name in python
    while True:
        print(input())
.
.
.

you will notice that your code already does what you want! Even though it doesn't look like so, the input is not interrupted, take a look at the program:

1
2
t3
his 4
iss 5
my 6
strin7
g 8

this iss my string 
9

The only change your code needs is to change restricted name in.

Jakub Bednarski
  • 261
  • 3
  • 9