Scrabble_score


#1


https://www.codecademy.com/courses/python-intermediate-en-rCQKw/1/3?curriculum_id=4f89dab3d788890003000096#


i expect the code works


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 scrable_score(word):
    # make word low case 
    minuscule_word = word.lower()
    # make minuscule_word a list
    minuscule_word = list(minuscule_word)
    # the sum 
    for char in minuscule_word:
        if score[char] in minuscule_word:
            total = 0
            total +=score[char]
            return total


#2

There is no need for a conditional in your function. Take the word, switch to lower and look it up in the table.

total = 0
for letter in word:
    total += score[letter]
return total

#3

thanks but still i have this msg error
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 scrable_score(word):
# make word low case
minuscule_word = word.lower()
# make minuscule_word a list
minuscule_word = list(minuscule_word)
# the sum
total = 0
for char in minuscule_word:

    total +=score[char]
return total

Oops, try again. Did you create a function called scrabble_score? Your code threw a "global name 'scrabble_score' is not defined" error.


#4

thanks that's works
def scrable_score(word):
# make word low case
minuscule_word = word.lower()
# make minuscule_word a list
#minuscule_word = list(minuscule_word)
# the sum
total = 0
for char in minuscule_word:
total+=score[char]
return total

print scrable_score("abdelkader")


#5

3 posts were split to a new topic: Scrabble score - having a bit of trouble


#6

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