Question: Write a program that counts the number of characters, words, and lines in a given file. Whitespace characters' separate words. The followings are required:
Write a program that counts the number of characters, words, and lines in a given file. Whitespace characters' separate words. The followings are required: a. The program should prompt the user to enter file name b. The program should read the file name from keyboard c. Make sure that the data file exists prior to reading it d. The program read the file contents and count the number of characters, words and lines the file has. The following diagram shows a sample of the program when it runs and read file Please enter file to be processed: test Document.txt Does the file exist in the system? YES Processing File test Document.txt 3087 Characters 476 words 83 Lines
Step by Step Solution
There are 3 Steps involved in it
Answer Certainly Below is a simple Python program that fulfills the specified requirements This prog... View full answer
Get step-by-step solutions from verified subject matter experts
