Why isn't my code running correctly? Scrabble_score


Can someone please explain why my code doesn't work.
def scrabble_score(word):
word = word.lower()
total = 0
for letter in word:
total += score[letter]
return total
print scrabble_score("xylophone")

It only returns the value of the first letter. I thought for loops translated as: for EACH blank in blank, then do this... If that is the way they are supposed to work than why does my code only return the value of the first letter?


if that is happening then the best guess is you have your return value inside the for loop. indent that line 4 spaces back(i.e move it out of the for loop)


Thank you!!! It worked.