It does not have any function which means that the wrong tool for the job has been employed. Sort of like hammering in a screw.
The table above is used for look-up purposes only, and we do not need to enumerate the word, only iterate over each letter in the word, and look up its score.
for letter in word.lower():
total += score(letter)
enumerate is a function that takes a list and enumerates it by adding an index. It returns an iterator made up of index/value pair tuples.
[(0, 'w'), (1, 'o'), (2, 'r'), (3, 'd')]
As we can see,
i is the index, or first value in the tuple, and
c is the text character, or second value of the tuple. A little more than we need in this instance, so overkill.
An interesting use of enumerate() would be if we wanted the index of the letter with the highest score in the word.
highest = 0
idx = 0
total = 0
for i, c in enumerate(word):
value = score[c]
if value > highest:
highest = value
idx = i
total += value
return word, total, word[idx], highest
_word = 'cyclopse'
print ("Word: %s\nWord score: %d\n\
Highest letter score: %s => %d " % score_and_highest(_word))
Word score: 17
Highest letter score: y => 4
The above assumes at least one of the letters is already on the board since there are only seven letters in the tray for any one turn.