Fix bug with last symbol in sample text

Since the last symbol doesn't transition anywhere, there are errors if
it happens to be the only occurrence of that symbol in the entire
sample.
Fix bug for Python 3, `keys()` must be cast to a list
Add `word` generator method to `MarkovChain` class