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
def score_words(word):
point_total = 0
for letter in word:
for letters in letter_to_points.keys():
if letter == letters:
point_total += letter_to_points[letter]
return point_total
brownie_points = score_words("BROWNIE")
player_to_words = {"player1":["BLUE", "TENNIS", "EXIT"], "wordNerd":["EARTH", "EYES", "MACHINE"], "Lexi Con":["ERASER", "BELLY", "HUSKY"], "Prof Reader":["ZAP", "COMA","PERIOD"]}
player_to_points = {}
for player, words in player_to_words.item():
player_points = 0
for word in words:
player_points += score_words(word)
return player_to_points[player]=player_points
I’m missing something here at the end and need help understanding were I have went wrong. It gives me a syntax error for the = in the last line. That is how you add a key and value to a dictionary so I’m thinking I must have missed a small step. Can anyone shed some light on this please? All help is greatly appreciated!