Code not working!


#1



score = {"a": 1, "c": 3, "b": 3, "e": 1, "d": 2, "g": 2, 
         "f": 4, "i": 1, "h": 4, "k": 5, "j": 8, "m": 3, 
         "l": 1, "o": 1, "n": 1, "q": 10, "p": 3, "s": 1, 
         "r": 1, "u": 1, "t": 1, "w": 4, "v": 4, "y": 4, 
         "x": 8, "z": 10}

def scrabble_score(score):
    word = raw_input("Enter a word!")
    count = 0
    for x in score:
        for n in word:
            if x==n:
                count += score[x]
    return count
    .


#2

This should not be inside the function.

We should not use a variable name that is already defined as a reference object. It will cause problems.

def scrabble_score(word):
    count = 0
    for x in word:
        count += score[x]
    return count

If you wish to learn something from this, then study the differences and resolve the logic.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.