newbie question: for loop within for loop confusion
lawtonpaul at gmail.com
Sun Jun 15 21:23:44 EDT 2008
I'm studying python via the exellent book "How to think like a python
programmer" by Allen Downey.
Noob question follows...
animals.txt is a list of animals, each on a separate line: "aardvard,
bat, cat, dog, elephant, fish, giraffe, horse, insect, jackelope"
I want to loop through the list of words and print words that don't
have any "avoid" letter in them.
fin = open('animals.txt')
for line in fin:
word = line.strip()
for letter in avoid:
if letter in word:
Why doesn't the function above work? It returns:
thanks for any help.
More information about the Python-list