There are many ways to control a running program, but to a first approximation all of them involve alternating between doing some work and checking for input. A very simple approach would be something like this:
import string
value = 1
def checkChangeValue():
newValue = input()
if newValue.isdigit():
global value
value = int(newValue)
def main():
print("Value is {}".format(value))
def loop():
main()
checkChangeValue()
if __name__ == '__main__':
while True:
loop()
This runs the main function ("do some work") and then checkChangeValue ("check for input") over and over. This may not do what you want, though, because input() waits for you to type something and hit enter, so it will block the execution of main. To get around this you could add threads:
import string
import threading
value = 1
def checkChangeValue():
global value
while True:
newValue = input()
if newValue.isdigit():
value = int(newValue)
def main():
print("Value is {}".format(value))
if __name__ == '__main__':
threading.Thread(target=checkChangeValue).start()
while True:
main()
Either of these methods may work, depending on your needs. For a more sophisticated approach you might look at the pynput library, which lets you interact with your program through keyboard or mouse input.
There are many other different ways of controlling a running program, too! You could communicate with your program through files, pipes, sockets, shared memory, etc. This in general is called "Inter-process communication" or IPC.