Dear list, out of "Thinking in Python" I take the following code, which "takes a word and a string of required letters, and that returns True if the word uses all the required letters at least once".
def uses_all(word, required): for letter in required: if letter not in word: return False return True Now, I want to feed this code a list of words. This is what I have so far: def uses_all(required): fin = open('words.txt') for line in fin: word = line.strip() for letter in required: if letter not in word: # print "False!" return False print word required = raw_input("what letters have to be used? ") print required uses_all(required) The code runs, but does not print the words. All I get it the output of the 'print required' command: da...@ubuntu:~/Documents/Tools/Python/Code$ python downey_9.5.py what letters have to be used? zhg zhg aa z da...@ubuntu:~/Documents/Tools/Python/Code$ I realise that my loop fails to execute beyond the first word in the list ("aa"), but why? Thanks in advance for your insights! David _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor