Scrabble


# A program that asks the user to enter a word, and it will
# compute and display the Scrabble score for the word.  


# Dictionary containing all the letters of the alphabet and their associated point value
scrabble_points = {"a":1, "e":1, "i":1, "o":1, "u":1, "l":1, 
                   "n":1, "r":1, "s":1, "t":1, "d":2, "g":2, 
                   "b":3, "c":3, "m":3, "p":3, "f":4, "h":4, 
                   "v":4, "w":4, "y":4, "k":5, "j":8, "x":8, 
                   "q":10, "z":10}


# Keeps count of the points for each letter
scrabble_sum = 0

word = input("Enter a word: ")

# Goes through each letter in the word inputted by the user
for letter in word:
    # Search for the key containing the letter and retrieving the point value
    point_value = scrabble_points.get(letter.lower()) # adding the lower() will prevent any errors if user enters any capitalized letters
    scrabble_sum = scrabble_sum + point_value

# Prints the word, then goes to a new line and prints the total points 
print(f"Word: {word} \nScrabble Score: {scrabble_sum}")