Skip to content

Instantly share code, notes, and snippets.

@promediacorp
Created March 15, 2014 16:30
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 promediacorp/9570030 to your computer and use it in GitHub Desktop.
Save promediacorp/9570030 to your computer and use it in GitHub Desktop.
Takes a list of prefixes and suffixes to generate word combinations.
#combines words together
import itertools
list_combined_words = []
fh_pre = open("foods.txt", "r")
fh_suf = open("shopping.txt", "r")
list_pre = [line.strip() for line in fh_pre.readlines()]
list_suf = [line.strip() for line in fh_suf.readlines()]
combined_list = itertools.product(list_pre, list_suf)
for x,y in combined_list:
list_combined_words.append(x + y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment