[Tutor] Newbie question

Grimmtooth grimmtoothtoo@yahoo.com
Sun, 3 Feb 2002 17:23:01 -0500


> I am trying to open a txt file and count the number of lines. I am
> trying to figure out if I need to use fileinput and lines() or will the
> readlines() also give me the count.

If you load the file into an array of one line per array member, you can
then arrive at the number of lines by using the len() function.  For
example:

And it so happens that the array you get from readlines() *is* one line per
member. Just use len() on the array you read into and you'll know.

One of the more endearing features of the language :-)



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com