I'm trying to create a program that will prompt the user for a list of text files to read from, then read those text files and build a dictionary of all the unique words found. Then finally put those unique words into another file and make it alphabetical order
from string import punctuation
def unique_words(sentence, number):
return [w for w in set(sentence.translate(punctuation).lower().split()) if len(w) >= number]
print (unique_words("This text is a sample text. It need to be parsed correctly.", 2))
I figured out how to make take the unique words out of a sentence but that's it. Can anyone help me out a little?