Need help playing scrabble


Stuck on this problem. I have it played out in my head but don't know how to go about doing it. Any help will be much appreciated

Replace this line with your code. 
def scrabble_score(word):
    total = 0
    for t in range(len(word)):


Think it through. Given a word, we need to identify each letter and then use the lookup table, scores to determine the score, then add that score to a running total. When the loop is finished, return the total. You have a good start.


Identify each letter in scores right ?


Correct. So how would we go about using the lookup table?


I'll give you a tip to help keep this simple. Since we are not manipulating any data, we do not need to use a range() when iterating over the word. We can use a lookup loop...

for letter in word:


Ok cool thanks for the tip. Now I just need to identify each letter in score, add the given word and return the total

def scrabble_score(word):
    word = word.lower()
    total = 0
    for letter in word:
        total += score[letter]
    return total

I got it correct. Thanks for the help.


This topic was automatically closed after 24 hours. New replies are no longer allowed.