butterflyTee 0 Light Poster

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. I use Gettysburg address.

#The number of lines, and the number of words.


import string


def main():
    data = raw_input("Enter the path and name of your ")
    infile = file(data, 'r')
    data_file = infile.read()
    number_of_characters = len(data_file)
    print "The number of characters in your text is", number_of_characters

    list_of_words = string.split(data_file)
    number_of_words = len(list_of_words)
    print "The number of words in your text is", number_of_words
    infile.close()

    secondfile = file(data, 'r')
    line_of_text = secondfile.readlines()
    print line_of_text
    number_of_lines = len(lines_of_text)
    print "The number of lines in your text is"  ,  number_of_lines

    infile.close()

main()