for ... else ?
why?
jimbomaan at gmail.com
Wed Jun 13 00:54:03 EDT 2007
> > > On 6/12/07, Gabriel Genellina <gagsl-... at yahoo.com.ar> wrote:
> > >> for x in iterable:
> > >> do something with x
> > >> else:
> > >> do something when there are no more x
> >
> > >> You can think the above as:
> >
> > >> while there are still values in iterable:
> > >> do something with the next value
> > >> else:
> > >> do something when there are no more items
@Gabriel--Hey thanx a lot! I had seen a similar 'for-else' clause
somewhere else as well and i was left wondering that how an 'else' got
coupled with 'for'. Anyways now am ok! This post clears a lot of
doubts.
More information about the Python-list
mailing list