Last active
October 9, 2018 15:10
-
-
Save mhbeals/b434f845decc5a1b452542a86dcdaa65 to your computer and use it in GitHub Desktop.
P4HSS Hints (Workshop 2)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First programme: | |
word_sub_list = [] | |
for word in my_words: | |
if word.startswith('t'): | |
word_sub_list.append(word) | |
print (', '.join(word_sub_list), end ='.') | |
# Final Programme: | |
ngram_list = [] | |
i = 0 | |
while i < len(my_words): | |
if my_words[i].startswith('to'): | |
ngram = ' '.join(my_words[(i-1):(i + 2)]) | |
ngram_list.append(ngram) | |
i = i + 1 | |
for ngram in ngram_list: | |
print (ngram) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment