# https://gist.github.com/54321ee9c0e5a46c0db8f14de3141d3a

#1

I am really struggling with this code here. I am trying to iterate through a loop to add the values associated to the keys of the argument in the function. So I’ve tried these two different lines, I knew one would not work because it doesn’t even address the proper argument. However, the other code that includes the proper argument give me a value of 630, which I just cannot understand why. Someone please help me understand what I’m doing wrong and how to correct it.

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

Returns a value of 630 for the argument “brownies”

def score_word(word):
point_total = 0
for value in letter_to_points.values():
point_total += value
return point_total

Returns a value of 90

#2

We are given a `score` dictionary with lowercase letter keys and corresponding values for each letter. It only takes one loop to iterate over `word`. Poll the score on the letter key and add the value to the total.

``````total = 0
for letter in word.lower():
total += score[letter]
``````
``````>>> scrabble_score('brownies')
13
>>> sum(score.values())
87
>>>
``````

#3

Thanks I’ll try that. I don’t think I learned the .lower() function. I was at first trying to use the .values() function, but it was giving me a list error. That’s why I tried the loop in a loop. Thanks again.

#4

So, in my original post i forgot to type that brownie was actually “BROWNIE”.

So I used this code (very similar to yours, just needed tweaking because of me not being specific enough), and it worked perfectly. Thank you very much for your help.

def score_word(word):
point_total = 0
for letter in word.upper():
point_total += letter_to_points[letter]
return point_total