Scrabble_score


#1



This is the error msg i have

"Oops, try again. Remember to make your function work for upper- and lowercase letters!"


But i get the right result with all CAPS, MIX of caps and lowercase and all lowercase. It looks like module wants me to assign same points for lower case and uppercase thus giving the final result same irrespective of caps, no caps and mixed string.

But dont you guys think this code can be one of the faster ways to get the result.

Please guide me if i am wrong


word = raw_input("Enter Word:").lower()
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(word):
    val = 0
    for i in word:
        if score[i] >0:
            val = val + score[i]
        
    return val
print scrabble_score(word)


#2

The lesson checker is not using your user input, and neither should you. That is not asked for, nor expected.

Conditional is not needed, and neither is it asked for. Follow the instructions closely and only use what is asked for.


#3

ok sir got it, modified and worked


#4

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