Data Science, Towards Data Science, Markov Chains, Monte Carlo, Simulation.
all up in a function, which I leave as an exercise to the reader. There are a lot of tools are there to ‘Markovify’ text, and I encourage you to look them up. But for someone just learning Markov chains, the code here is an easy place to start. But there are endless possibilities for improvement.