Python script to generate output text using a Markov chain and input text