Scrabble score


#1



Why doesnt this code work? It says "Your function fails on scrabble_score("pie"). It returns "None" when it should return "5"."


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,"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}
         
import math

def scrabble_score(word):
    the_list = []
    for i in word: 
        the_list.append(score[i])
    print sum(the_list)
    


word = raw_input("Enter text here: ") 
print scrabble_score(word)


#2

It complains about what you return, does your function return anything?


#3


#4

If you mean to show that something is printed, then that's not what is asked for, nothing has been said about printing.


#6

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