Given a Dictionary and a list of letters, find all possible words that can be created with the letters
<p>The function scoreList(Rack) takes in a list of letters. You are also given a global variable Dictionary: <code>["a", "am", "at", "apple", "bat", "bar", "babble", "can", "foo", "spam", "spammy", "zzyzva"]</code>. </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>MyCode:</p>

<pre><code>def scoreList(Rack):
    test = [x for x in Dictionary if all(y in Rack for y in x)]
    return test
</code></pre>

<p>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 was able to find the words, but not the score. How could I find it without using dict?</p>

<p>Below is the sample code to achieve this:</p>

<pre><code>score = [["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]]

my_list = ["a", "am", "at", "apple", "bat", "bar", "babble", "can", "foo", "spam", "spammy", "zzyzva"]
score_dict = dict(score)  # Storing score value as dict

def get_word_score(my_list):
    return [(item, sum(score_dict[a] for a in item)) for item in my_list]

get_word_score(my_list)
# returns: [('a', 1), ('am', 4), ('at', 2), ('apple', 9), ('bat', 5), ('bar', 5), ('babble', 12), ('can', 5), ('foo', 6), ('spam', 8), ('spammy', 15), ('zzyzva', 39)]
</code></pre>

python list dictionary