'''counter.py Jeff Ondich, 9/9/09 This program counts the number of lines in a file specified by the user. It also counts the number of lines at least 80 characters long. To test this program, create a text file (called, say, testdata.txt) with a bunch of lines, plus at least one line that's longer than 80 characters. Then run python counter.py File name, please: testdata.txt ... to see how many lines and how many long (>= 80) lines are in the file. ''' fileName = raw_input('File name, please: ') file = open(fileName) numberOfLines = 0 numberOfLongLines = 0 for line in file: numberOfLines = numberOfLines + 1 if len(line) >= 80: numberOfLongLines = numberOfLongLines + 1 file.close() print 'The number of lines in', fileName, 'is', numberOfLines print 'The number of long lines (80 chars or more) is', numberOfLongLines