Quotes help make search much faster. Example: "Practice Makes Perfect"

Thursday, November 29, 2012

Codecademy: scrabble_score


#sample solution


def scrabble_score(word):
word = word.lower()
#print "word in lowercase: " + word
sum = 0
for c in word:
for key in score:
if c == key:
#print score[c]
sum = sum + int(score[c])
return sum

2 comments:

  1. Hi, I am not sure why my code is not working:
    def scrabble_score(word):
    #key=score.key
    total =0
    #value= score.values
    value=[]
    new_value=[]
    word=word.lower()
    for i in word:
    new=score[i],
    value.append(new)
    #value.append(word[i])
    #return value
    for num in value:
    if num != " ":
    total +=num
    return total
    pass
    print total

    ReplyDelete
  2. Hi, I am not sure why my code is not working:
    def scrabble_score(word):
    #key=score.key
    total =0
    #value= score.values
    value=[]
    new_value=[]
    word=word.lower()
    for i in word:
    new=score[i],
    value.append(new)
    #value.append(word[i])
    #return value
    for num in value:
    if num != " ":
    total +=num
    return total
    pass
    print total

    ReplyDelete


This is an example of scrolling text using Javascript.

Popular Posts