newbie question: for loop within for loop confusion
David
david at abbottdavid.com
Mon Jun 16 22:02:03 EDT 2008
takayuki wrote:
> Paul,
>
> Thank you for the informative reply.
>
> Yes, I created the indent problem when manually copying the original
> script when I posted. (I'm using an old laptop to study python and
> posting here using the desktop.)
>
> Your examples really helped. Last night I played with using a for
> loop instead of a while loop and got it working, but your examples
> really clarified things.
>
> This loop was particularly interesting because I didn't know the else
> could be attached to the for. Attaching it to the for solved a lot of
> problems.
>
> for letter in avoid:
> if letter in word:
> break
> else:
> print word
>
>
> I've printed out this whole thread and will be playing with your and
> others' solutions.
>
> I love this one for its conciseness, but will have to play with it to
> get my head around it.
>
> if not any(letter in word for letter in avoid):
> print word
>
> Thanks again.
>
> takayuki
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
>
takayuki,
Could you post the complete script.
thanks
david
--
Powered by Gentoo GNU/LINUX
http://www.linuxcrazy.com
More information about the Python-list
mailing list