Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me with this question Finding Unique Words in a File In this exercise you will read the words contained in a file and

Please help me with this question

Finding Unique Words in a File In this exercise you will read the words contained in a file and process them. Your program must create a list of the unique words found in the file (ignoring case). Words are only composed of alphabetic characters; digits and punctuation should be removed. Write a fruitful function named open_file() that prompts the user for a file name. The function then attempts to open the file for reading. When it is successful it returns the file handle. If the named file is not readable then the function displays a message and prompts for another file name. Use the os.path.isfile() function to check to see if the file exists. Do not use exception handling in this program. Write a main driver that uses open_file() to get a file handle for the file that the user requests. Then reads the file extracting all the words ignoring punctuation and non-alphabetic characters. Either during the reading process or after the entire file has been read (your choice) create a list containing the unique words. Change all words to lowercase before you process them. Then display a list of these words sorted in alphabetic order. As one of the tests for your final submission you should use the text of Robert Frosts Fire and Ice which is contained in FireAndIce.txt. You also should use Leunigs How To Get There contained in GettingThere.txt.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Finance The Role Of Data Analytics In Manda Due Diligence

Authors: Ps Publishing

1st Edition

B0CR6SKTQG, 979-8873324675

More Books

Students also viewed these Databases questions

Question

What leader behaviors would you recommend to Ted? Why?

Answered: 1 week ago