Skip to content

Instantly share code, notes, and snippets.

@mhbeals
Last active October 9, 2018 15:10
Show Gist options
  • Save mhbeals/b434f845decc5a1b452542a86dcdaa65 to your computer and use it in GitHub Desktop.
Save mhbeals/b434f845decc5a1b452542a86dcdaa65 to your computer and use it in GitHub Desktop.
P4HSS Hints (Workshop 2)
# 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