"Noah Hall" <enali...@gmail.com> wrote
What you want is something that takes the length of each line,
and add it to the sum. A simple way would be to do
sum(len(line) for line in file)
And if you just want the total count for the file an even
simpler way is to use file.read()
count = len(file.read())
One other thing to consider is whether you want to include
line feed characters in the count...
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor