Question: Python: The program asks the user for three pieces of information. A text file to open A letter to search for A position to look
Python:
The program asks the user for three pieces of information.
A text file to open
A letter to search for
A position to look in
The program counts how many words have the given character in the correct position. For example, the previous sentence contains 5 words with 'o' in position 1.
Your program must check for errors. If an error is encountered, call sys.exit(0) after printing a message.
If the file cannot be opened, then print an error. (Hint: Use a try/except with OSError)

Welcome to Book Analyzer v0.1 Enter File Name to Read: fake name.txt Error: Could Not Open Filc Print an error if something other then a single letter is given to search for Enter Filc Name to Rcad: modest.txt Letter to search for: A Bad Input Error: A single letter is required. Print an error if the third input is not a number Welcome Lo Book Analyzer v0.1 EnLer File Name Lo Read: modesL. LxL LeLLer Lo search Lor: al Enter Position (O for first letter) T'WO Error A number is required. If all inputs are good, then you can read the file. Get each word out of the file and check it against the inputs. Count how many words appear with the character given in the correct location Wel come to Book Ana l yzer vO.1 Enter File Name to Read: modest..t.xt. Tetter to search for: Enter Position (0 for first letter): Thereare 853 words with h in position 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
