Question: how could i do to improve python Write a program that prompts the user to enter a filename and prints a list of all the





how could i do to improve
python
Write a program that prompts the user to enter a filename and prints a list of all the words in the file converted to lowercase, then sorted into alphabetical order. Note: the file may include duplicate words. If the file contains the same word more than once, however, it must only appear in the list ONCE You can assume that the file is a plain text file without any punctuation marks. Input Result testi.txt Enter filename: testi.txt ['a', 'file', 'line', 'one', 'only', 'simple', 'wit x = input("Enter filename: ") my_list = [] y = open(x, "r") Z = y.reado 5 ly.close() Z = z.split(" ") 7 z.sort () 8 for element in Z: 9 element.lower() my_list.append(m) 11 print (my_list) m = Input Expected test1.txt Enter Filename ['a', 'file's 'line', 'one's 'one', only 'simpli test2.txt Enter filename: test2.txt ['file', five has lines: this'] summer .txt Enter filename: Summer.txte ['a', after''and', are autumn', 'beer Some hidden test cases failed to Got Enter filename: testi.txt ['a', 'file', 'line'; one's only...simple', 'with'] Enter filename: test2.txt 'this in "filen', 'five n', 'ha Enter filename: Summer.txt 1 nthe', Summer tortoise 'tortoise tortoise', a and
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
