Scrabble score:


#1

def scrabble_score(word):
total = 0
for i in word:
if i in score:
total = total + score[i]
print (total)
return total
scrabble_score("afdg")

IT GIVES ERROR MESSAGE::Oops, try again. Your function fails on scrabble_score("pie"). It returns "3" when it should return "5".

CAN ANYONE EXPLAIN ABOUT THE PROBLEM IN THIS CODE::
THANKX IN ADVANCE


#2

Problem is return statement, when function reaches return statement ,it simply halts it ,break outs of the function and your code is not able to calculate total scrabble value for a word.

Make sure that final return statement is not part of your for loop!

One more thing...
convert your word to lower case.
word.lower() as scrabble score is for lowercased letters.

also check this thread..


#3

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