How do you execute a function while Python 3 is taking input from the user?

Viewed 103

How do you execute a function, while the program is still taking input from the user, because all the code after

user_input = input()

is not run until the user inputs something.

So how do I run a function while the user is typing an input?

Thank you!

Edit: People were asking why I need to do this, so I am making an online TextRPG game, where people can chat as well, but what I want is while you are typing, chat should update. Also I have not tried any code yet, because I don't get how to do it.

2 Answers

You can use the concept of multi threading.

test_number = int(input("Enter a number: "))
Related