SPOILERS - SOLUTION AHEAD
Hi.
I’m new and like feedback. What could I have done better?
Here’s how I did the Scrabble Project:
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 = dict(zip(letters, points))
letter_to_points[""] = 0
def score_word(word): return sum([letter_to_points.get(char.upper(), 0) for char in word])
player_to_words = {
"player1": ["blue", "tennis", "exit"],
"wordNerd": ["earth", "eyes", "machine"],
"Lexi Con": ["eraser", "belly", "husky"],
"Prof Reader": ["zap", "coma", "period"]
}
player_to_points = {player: sum([score_word(word) for word in player_to_words[player]]) for player, words in player_to_words.items()}
print(player_to_points)