I'm doing a project with word lists. I want to combine two word lists, but only store the unique words.
I'm reading the words from a file and it seems to take a long time to read the file and store it as a list. I intend to copy the same block of code and run it using the second (or any subsequent) word files. The slow part of the code looks like this:
while inLine!= "":
inLine = inLine.strip()
if inLine not in inList:
inList.append(inLine)
inLine = inFile.readline()
Please correct me if I'm wrong, but I think the slow(est) part of the program is the "not in" comparison. What are ways I can rewrite this to make it faster?