Find all combinations of a list
<p>The function scoreList(Rack) takes in a list of letters. You are also given a global variable Dictionary: ["a", "am", "at", "apple", "bat", "bar", "babble", "can", "foo", "spam", "spammy", "zzyzva"].</p>

<p>Using a list of letters find all possible words that can be made with the letters that are in the Dictionary. For each word that can be made also find the score of that word using scrabbleScore.</p>

<p>scrabbleScore =</p>

<pre><code>   [ ["a", 1], ["b", 3], ["c", 3], ["d", 2], ["e", 1], 
     ["f", 4], ["g", 2], ["h", 4], ["i", 1], ["j", 8], 
     ["k", 5], ["l", 1], ["m", 3], ["n", 1], ["o", 1], ["p", 3], 
     ["q", 10], ["r", 1], ["s", 1], ["t", 1], ["u", 1], ["v", 4], 
     ["w", 4], ["x", 8], ["y", 4], ["z", 10] ]
</code></pre>

<p>I can use expressions made up of list comprehensions(map, filter, reduce, etc.), if statements, and for loops but only if they are in the context of a list comprehension.</p>

<p>Example:</p>

<pre><code>&gt;&gt;&gt; scoreList(["a", "s", "m", "t", "p"])
[['a', 1], ['am', 4], ['at', 2], ['spam', 8]]
&gt;&gt;&gt; scoreList(["a", "s", "m", "o", "f", "o"])
[['a', 1], ['am', 4], ['foo', 6]]
</code></pre>

<p>The order in which they are presented does not matter. It also must remain a list and not a dic. Would love some help with this problem or if you could give me a better understanding of how to use map or filter in this problem.</p>

<p>My Code so far:</p>

<pre><code>def scoreList(Rack):
result = [d for d in Dictionary if all(l in Rack for l in d)]
return result
</code></pre>

<p>My Output:</p>

<pre><code> &gt;&gt;&gt; scoreList(["a", "s", "m", "t", "p"])
    ['a', 'am', 'at', 'spam']
</code></pre>

<p>As you can see I have found out how to output the words but not the score. I also haven't figured out how to implement the use of map, filter, or any other list comprehensions.</p>

<p>Apparently you're asking the same question repeatedly (according to a comment on your question). So I'm going to answer this as thoroughly as possible</p>

<p>You seem to have a scrabble dictionary in a list called <code>Dictionary</code>. I'm going to move forward from that point:</p>

<pre><code>import itertools

def scoreList(rack):
    points = dict([ ["a", 1], ["b", 3], ["c", 3], ["d", 2], ["e", 1], 
                 ["f", 4], ["g", 2], ["h", 4], ["i", 1], ["j", 8], 
                 ["k", 5], ["l", 1], ["m", 3], ["n", 1], ["o", 1], ["p", 3], 
                 ["q", 10], ["r", 1], ["s", 1], ["t", 1], ["u", 1], ["v", 4], 
                 ["w", 4], ["x", 8], ["y", 4], ["z", 10] ])

    validWords = set(Dictionary)
    answer = []
    for l in range(1, len(rack)):
        for word in itertools.permutations(rack, l):
            if not word in validWords: continue
            answer.append(word, sum(points[char] for char in word))
    return answer
</code></pre>

python list