# Scrabble Project "brownie points"

I don’t really know what is wrong with my code, but for some reason when I call for var(brownie_points)
it returns as a value of 3 not 15. If anyone can tell me what’s wrong that would be great. TIA!

``````letter_to_points = {key:value for key, value in zip(letters,points)}

letter_to_points[" "] = 0
print(letter_to_points)

def score_word(word):
point_total = 0
for letter in word:
point_total += letter_to_points.get(letter, 0)
return point_total

browine_points = score_word("BROWNIE")

print(browine_points)
``````
letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] points = [1, 3, 3, 2, 1, 4, 2, 4, 1, 8, 5, 1, 3, 4, 1, 3, 10, 1, 1, 1, 1, 4, 4, 8, 4, 10] letter_to_points = {key:value for key, value in zip(letters,points)} letter_to_points[" "] = 0 print(letter_to_points) def score_word(word): point_total = 0 for letter in word: point_total += letter_to_points.get(letter, 0) return point_total browine_points = score_word("BROWNIE") print(browine_points)

You have the return inside the for-loop,
so the function ends after the first iteration of the loop (so it only scores the first letter).

Change the indentation on that line so that the return is not inside the loop.

2 Likes