I got a file wordlist.txt with 100 random words in it, each on a separate line. I currently use the following code to grab 12 random words from this file. To avoid picking exactly the same 12 words i want to builtin an extra check. The 12 random words are written to output.txt. How can i make my script compare the 12 random words (in the same order) with the 12 random words i have in output.txt (in 1 line)?
I currently use the following to read 12 random words from wordlist.txt and write them to output.txt:
teller = 0
while True:
teller += 1
#Choose 12 random words and write to textfile
print "\nRound",teller
f1=open('output.txt', 'w+')
count = 0
while (count<12):
f1.write(random.choice([x.rstrip() for x in open('wordlist.txt')])+ " ")
count += 1
f1.close()