Skip to content

Instantly share code, notes, and snippets.

Last active Jul 18, 2018
What would you like to do?
Warmup solution
import nltk
from nltk.corpus import words
# print(words.words())
words = words.words()
phrase = "ada lovelace".lower().replace(" ", "")
longest_word = ""
for word in words:
iw = 0
for ip in range(0, len(phrase)):
if phrase[ip] == word[iw]:
iw += 1
if iw == len(word):
# The word was a match
if len(word) > len(longest_word):
longest_word = word
print("Longest word is {0} length {1}".format(longest_word, len(longest_word)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment