Last active
July 18, 2018 18:20
-
-
Save parkercoleman/c8261ad388c33e2f4bcfde00b74b9759 to your computer and use it in GitHub Desktop.
Warmup solution
This file contains 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
import nltk | |
from nltk.corpus import words | |
# nltk.download() | |
# 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 | |
break | |
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