Skip to content

Instantly share code, notes, and snippets.

@lavie
Created August 31, 2018 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lavie/c55539277bd991a6c0bf2a61b7585a02 to your computer and use it in GitHub Desktop.
Save lavie/c55539277bd991a6c0bf2a61b7585a02 to your computer and use it in GitHub Desktop.
base=wordlist[0] #consider the first word in the list
for word in wordlist: #loop through the entire list checking if
if not word.startswith(base): # the word we're considering starts with the base
print base #If not... we have a new base, print the current
base=word # one and move to this new one
#else word starts with base
#don't output word, and go on to the next item in the list
print base
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment