Home > Mobile >  Can I continue an input after a new line is created
Can I continue an input after a new line is created

Time:04-10

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.

CodePudding user response:

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.

  • Related