textfile=open('somefile.txt','r')
text_list=[line.split(' ') for line in textfile]
unique_words=[word for word in text_list if word not in unique_words]
print(len(unique_words))
That’s the general gist of it
solved how do I count unique words of text files in specific directory with Python? [closed]