Question: Your program will take a file name from user, access the file and find out all the words in the file and list them in

Your program will take a file name from user, access the file and find out all the words in the file and list them in alphabetical order. Make sure every word is listed only once. Also state how many words are found in the file as sample output shows.
Also, ask user if user wants to repeat and depends on the answer, your program needs to terminate or repeat.
If user enters wrong information (wrong name of the file or non-existing file name), your program needs to display message and ask for correct input. Your program should not generate traceback message with any input.
OUTPUT:
============================================
Enter file name: ch8-data1.txt
['a', 'add', 'an', 'and', 'applications', 'assistant', 'capable', 'different', 'digital', 'do', 'end', 'hardware', 'helpful', 'helping', 'is', 'many', 'of', 'operating', 'personal', 'programmers', 'quite', 'set', 'system', 'that', 'the', 'things.','to','up','us','we', 'with']
File ch8-data1.txt has 31 different words
Do you want to try another file? (y or n)y
Enter file name: aaaaa
file not found, please enter correct file name.
Enter file name: Ch8-data2.txt
['amounts', 'and', 'are', 'be', 'behalf', 'best', 'boring', 'can', 'computer', 'computers', 'could', 'do', 'explain', 'fast', 'find', 'have', 'helpful', 'humans', 'if', 'interestingly,','it', 'kinds', 'knew', 'language', 'like', 'memory', 'mind', 'next', 'numbing.','of', 'often', 'on', 'only', 'our', 'repetitive.', 'speak', 'tasks', 'tell', 'that', 'the', 'things', 'this', 'to','us', 'vast', 'very', 'we', 'were', 'what', 'would']
File Ch8-data2.txt has 50 different words
Do you want to try another file? (y or n)
Thank you for playing.
>>>

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!