Cc_markov.py -- conversion error to python 3?


#1

Hello, I am working on the final project - Markov Chains and keep getting an error message relating to the cc_markov.py file. Line 73. The error message is:
TypeError: ‘dict_keys’ object does not support indexing

From my brief googling, it looks like this may be related to switching from python 2 to 3. (I am coding in python 3). Since I did not write the cc_markov.py file, it’s a little hard to de-bug. Can you give me some more clarification or documentation about what each of the functions is doing in that file?

Also, do you know of anything that would have to be changed to convert this file to a python 3 file? It seems that dict.keys() is the main culprit at the moment, but not sure if there is anything else to be concerned with.

Thanks!

My project is not completed yet, but you can find the current version on github here.


#2

in python2 .keys() generate a list type, where in python3 it generates a dict-keys type. List supports indexing, where as dict-keys does not.

the simplest solution would be to convert to list, or see if unpacking (>= python3.5) is better.