Data Science, Towards Data Science, Markov Chains, Monte Carlo, Simulation.
pair is already a key in the dictionary, simply append the next word to the list of words that follow that word. Otherwise, initialize a new entry in the dictionary with the key equal to the first word and the value a list of length one: word_dict = {} for word_1, word_2 in pairs: if word_1 in