Question on loops
Daniel H Neilson
google at neilson.sent.com
Mon Mar 8 09:40:15 EST 2004
"Delaney, Timothy C (Timothy)" <tdelaney at avaya.com> wrote in message news:<mailman.109.1078711865.19534.python-list at python.org>...
> > From: Daniel H Neilson
> >
> > i = 0
> > for line in file:
> > if i == 100:
> > action
> > i = 0
> > else:
> > i += 1
> > process(line)
<snip>
> If you're using Python 2.3.x
>
> for i, line in enumerate(file):
> if i % 100 == 0:
> action
>
> process(line)
>
> Tim Delaney
Beautiful. Thanks to those who responded. DHN
More information about the Python-list
mailing list