In python 3.8:
f = open(input("Enter the name of your file (with the extension): "), "r")
l = sorted(set(f.read().split()))
for x in l:
print(x)
If your text file was named TextDocument, you would have to enter: TextDocument.txt
6.6m questions
8.7m answers