Another way to write the loop using a for each instead of a standard for loop would be:
def ngram_creator(text_list):
ngrams = []
lastword = None
for word in text_list:
if lastword:
ngrams.append('{} {}'.format(lastword, word))
lastword = word
return ngrams
Wow that is so much easier. I had a hard time remember so much of the text/string lessons. Even just a week between doing the main lessons and the capstone put a damper on how to implement.
Another way to write the loop using a for each instead of a standard for loop would be: