これをより良く、またはよりシンプルにする方法はありますか? 大量の単語が生成されることはわかっていますが、1 つの文に 4 行以上を結合しようとすると、本来の形に見えません。
infile = open('Wordlist.txt.txt','r')
wordlist = []
for line in infile:
wordlist.append(line.strip())
infile.close()
outfile = open('output.txt','w')
for word1 in wordlist:
for word2 in wordlist:
out = '%s %s' %(word1,word2)
#feel free to #comment one of these two lines to not output to file or screen
print out
outfile.write(out + '\n')
outfile.close()