On Mon, Aug 24, 2009 at 8:58 PM, kreglet <kreg...@gmail.com> wrote: > > Wayne, > > > def myfunc(cmpword, mainword): > > for letter in cmpword: > > if mainword.gets(letter): > > if cmpword[letter] >mainword[letter]: > > return False > > else: > > return False > > I tried your function and couldn't get it to work. It threw an error in > the > line "if mainword.gets(letter):" saying that "gets" was not an attribute of > dictionary. I tried it with "if mainword.get(letter):" -- no s but that > would't work either.
sorry, 'get' is what I meant. You also need to add "return True" on the same level as the else. In [5]: word1 = {'d':1, 'o':1, 'g':1} In [6]: word2 = {'g':1, 'o':1} In [7]: in_word(word2, word1) Out[7]: True In [24]: word2 = {'b':1, 'a':1, 'r':1} In [25]: in_word(word2, word1) Out[25]: False HTH, Wayne
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor