Created
March 15, 2014 16:30
-
-
Save promediacorp/9570030 to your computer and use it in GitHub Desktop.
Takes a list of prefixes and suffixes to generate word combinations.
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
#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