newbie question: for loop within for loop confusion

takayuki lawtonpaul at
Tue Jun 17 02:48:17 CEST 2008


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

for letter in avoid:
	if letter in word:
	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.


More information about the Python-list mailing list