9/15 scrabble_score


#1




I'm not sure if my word.lower() isn't converting the word into all lowercase.


Replace this line with your code. 
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):
    word.lower()
    total = (0)
    for i in range(0, len(word)):
        total = total + score[word[i]]
    return  total


#3

"Oops, try again. Remember to make your function work for upper- and lowercase letters!" is what I keep getting.

It works if I include the uppercases in the dictionary though.
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}


#4

well you're just saying word.lower()
it's not going to make a difference if you don't assign it to something. Try to think about it, if you just write word.lower(), what are you really saying? what do you expect it to do?
I think that you expect it to make the variable word lowercase, but for that, you need to write

word = word.lower()

#5

I can't believe I missed that.
Thank you.


#6

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