Hi, I've been asked to write a program using Python to count the number of words in a sentance. The exact task is outlined below:
Write a Python Program to count:
(i) the number of lines
(ii) the number of word
(iii) the number of character
in a text file and output the results in the following format:
Input filename: xxxxxx (the name of the input filename as provided by the user)
Total number of word: nnn
Total number of line: nnn
Total number of character: nnn
A “word” in this case is defined as a contiguous sequence of non-white-space characters (hint: split()). Character includes white (blank) spaces.
The input text file shall contain alphabet characters and white spaces only and could have any number of lines.
Can anybody help me?
Thank you!