Hi
Am trying to get my head around using with in some code which is putting 2 files together using random.choice. How do I prevent repeats with random.choice?
with open(name, "r") as f1:
beginnings = [word.rstrip(" \n") for word in f1]
with open("conjunct.txt", "r") as f2:
endings = [word.rstrip(" \n") for word in f2]
with open(name, "w") as f3:
for beginning in beginnings:
f3.write('%s %s' % (beginning, random.choice(endings)))
f3.write(os.linesep)
Thanks for any assist,
jkrueger