In: Computer Science
Write a program in python that opens a text file, whose name you enter at the keyboard.
•You will be using the file filetext.txt to test your program
•Print out all of the individual, unique words contained in the file, in alphabetical order.
MAKE SURE THAT ALL THE WORDS YOU PRINT OUT ARE IN A SINGLE COLUMN, ONE WORD PER COLUMN!•Print out the number of unique words appearing in text.txt
filename = input('Enter file name ')
with open(filename, 'r') as file: # open the file in read mode
list_of_words = [] # initialize a list
for i in file.readlines(): # loop through file data
li = i.split( ) # split each line by space
for j in li: # loop through each element and append it to the list_of_words list
list_of_words.append(j)
list_of_words = [i.lower() for i in list_of_words] # convert every element to lowercase
list_of_words = list(dict.fromkeys(list_of_words)) # remove duplicate elements from the list
list_of_words.sort() # sort words in alphabetical order
for i in list_of_words: # print elements in list_of_words
print(i)

