Markov Chain .py file Changes to Work with Python 3


this is for anyone that wants to complete the project in Python 3. I made very few changes, but i wanted to save anyone else the trouble of doing the research and testing to figure out what needed to be changed in order for this to work with Python 3.

the changes were:

line 71 chain_head = list(list(self.lookup_dict.keys())[idx]) - dict.keys() in python 2 returned a list, in 3 it doesn’t
line 57 range(len(data) - self.num_key_words) - this used to be xrange, there is no xrange in python 3

you need to print out the generate_text() method to get any output as the method only returns a list of strings and does not print them out.