Asrarahmed Kadri said unto the world upon 19/10/06 12:55 PM: > My algorithm is like this: > first count the number of lines in the file by using a loop. > Use a second loop and when teh counter reaches the num_of_lines values: > take > the line. > > Is there any other way to do it?? > > > > On 10/19/06, Danny Yoo <[EMAIL PROTECTED]> wrote: >> >> >> >> On Thu, 19 Oct 2006, Asrarahmed Kadri wrote: >> >> > I want to extract the last line of the text file. Any idea ??? >> >> Hi Asrarahmed, >> >> Ok, so what part do you get stuck on when you try to do this? That is, >> what sort of things do you already know how to do with files? >>
Hi Asrarahmed, one way would be to use the readlines method of the file object. That will get you a list of lines. From that, you could slice out the last line. Would you know how to do that? If not, ask again. Best, Brian vdB _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor