Re: [Tutor] Help required to count no of lines that are until 1000 characters

2010-05-12 Thread Alan Gauld
"Dave Angel" wrote But you have a serious bug in your code, that nobody in the first five responses has addressed. That while loop will loop over the first line repeatedly, till it reaches or exceeds 1000, regardless of the length of subsequent lines. Oooh, good catch, I completely miss

Re: [Tutor] Help required to count no of lines that are until 1000 characters

2010-05-11 Thread Dave Angel
ramya natarajan wrote: Hello, I am very beginner to programming, I got task to Write a loop that reads each line of a file and counts the number of lines that are read until the total length of the lines is 1,000 characters. I have to read lines from files exactly upto 1000 characters. Her

Re: [Tutor] Help required to count no of lines that are until 1000 characters

2010-05-11 Thread Alan Gauld
"spir ☣" wrote Either you read line per line, but then you cannot stop exactly at the 1000th character; or you traverse the text char per char, but this is a bit picky. Or you could just read 1000 chars from the file then pick out the lines from that. But that requires you to count newlin

Re: [Tutor] Help required to count no of lines that are until 1000 characters

2010-05-11 Thread शंतनू
On 12-May-2010, at 12:32 AM, spir ☣ wrote: > On Tue, 11 May 2010 11:00:20 -0700 > ramya natarajan wrote: > >> Hello, >> >> I am very beginner to programming, I got task to Write a loop that reads >> each line of a file and counts the number of lines that are read until the >> total length of

Re: [Tutor] Help required to count no of lines that are until 1000 characters

2010-05-11 Thread spir ☣
On Tue, 11 May 2010 11:00:20 -0700 ramya natarajan wrote: > Hello, > > I am very beginner to programming, I got task to Write a loop that reads > each line of a file and counts the number of lines that are read until the > total length of the lines is 1,000 characters. I have to read lines fro

Re: [Tutor] Help required to count no of lines that are until 1000 characters

2010-05-11 Thread Luke Paireepinart
On Tue, May 11, 2010 at 1:00 PM, ramya natarajan wrote: > Hello, I have to read lines from > files exactly upto 1000 characters. >But the problem is its reading entire line and not stopping > excatly in 1000 characters. Can some one help what mistake i am doing here?. > >    log = open('/tmp/new.t

[Tutor] Help required to count no of lines that are until 1000 characters

2010-05-11 Thread ramya natarajan
Hello, I am very beginner to programming, I got task to Write a loop that reads each line of a file and counts the number of lines that are read until the total length of the lines is 1,000 characters. I have to read lines from files exactly upto 1000 characters. Here is my code: I created fil