I've been working on some exercises, and have run into a problem with one of them.
The prompt:
"Scrabble is a board game, where a word is worth as many points as the sum of its letters. Write a function that calculates the point value of a word.
- The function is called scrabble_word
- It has two parameters:
pointtable, a dictionary containing the point values of all of the letters, andwordthe actual word: a list of letters - Your objective is to return the sum of the point values of the letters."
I saw an example where we find the sum of values of dict so i tried to do it that way:
def scrabble_word(pointtable, word):
s=0
for k in word:
s += word[k]
return s
It was wrong, then I realized the word is a list, and changed it a bit:
def scrabble_word(pointtable, word):
s=0
for i in range(len(word)):
s += pointtable[i]
return s
It still wrong. Should I define the values first? Can you help me?