I got to know what you have been asked to do with your Python program, before I can tell you if you did it right!

Word Count. A Common Utility On Unix/linux Systems Is A Small Program Called "wc." This Program Analyzes A File To Determine The Number Of Lines, Words, And Characters Contained Therein. Write A Version Of Wc. The Program Should Accept A File Name As Input And Than Print Three Numbers Showing The Count Of Lines, Words, And Characters In The File.

Here is simplified approach, the number of new-line characters '\n' give number of lines, the number of spaces are approximately the number of words, and the number of characters is the length of the text string read from file.

You simply use a for loop and and iterate each character in text counting new-lines, spaces. Don't have Unix and don't know if space counts as a character, also new-line. Can use char_from_text.isalnum() to weed these out.

You can also use, I didn't test, number_of_lines = text.count('\n') function.

A more correct answer for the number of words can be obtained by splitting the text string into list of words with word_list = text.split() and then get length of this list with number_words = len(word_list).

Here is simplified approach, the number of new-line characters '\n' give number of lines, the number of spaces are approximately the number of words, and the number of characters is the length of the text string read from file.

You simply use a for loop and and iterate each character in text counting new-lines, spaces. Don't have Unix and don't know if space counts as a character, also new-line. Can use char_from_text.isalnum() to weed these out.

You can also use, I didn't test, number_of_lines = text.count('\n') function.

A more correct answer for the number of words can be obtained by splitting the text string into list of words with word_list = text.split() and then get length of this list with number_words = len(word_list).
i having problem using this set up, can u please help me
C:\home\COP1000\a\3>python wc.py futval.py test.txt wc.py
22 103 699 futval.py
2 4 22 test.txt
52 223 1683 wc.py
76 330 2404 total

This question has already been answered. Start a new discussion instead.