[Tutor] Scrabble Help

William Allison allison.william at gmail.com
Sun Sep 5 17:45:30 CEST 2010


I'd like to write a program to help find words for Scrabble but I've
been having trouble
right from the beginning.

tiles = 'aeirstw'

dictionary = ['aardvark', 'cat', 'dog', 'taste', 'stare', 'wrist']

for word in range(len(dictionary)):
    for letter in range(len(dictionary[word])):
        if dictionary[word][letter] in tiles:
            nothing here quite works

I guess what I'm trying to do is step through every letter of every
word in my dictionary
and if that letter is in my tiles set it aside and compare it back to
the dictionary.  So in
the dictionary above, 'aardvark' would not be included because there
is only 1 'a' in my
tiles, but 'stare' and 'wrist' should be even though there are letters
left over in the tiles.

Am I going about this wrong?  Should I be looking at some module or a
regular expression?
Of course any advice is appreciated.
Thanks,
Will


More information about the Tutor mailing list