Write a program that will compute the score of a given word in a game of Scrabble. Assume that there are no special squares present. The program should prompt the user to input a string that only contains letters, and then compute the total score of that string by summing the value assigned to each letter. If the user inputs a string that contains invalid characters, the program should prompt for additional input until a valid word is received.
def main():
main()
def get_input():
def main():
word = get_input()
main()
def get_input():
word = input("Enter a single word: ")
while # word is not valid
print("Error! Invalid Input!")
word = input("Enter a single word: ")
return word
def main():
word = get_input()
main()
def get_input():
word = input("Enter a single word: ")
while not word.isalpha():
print("Error! Invalid Input!")
word = input("Enter a single word: ")
return word
def main():
word = get_input()
main()
def compute_score(word):
def compute_score(word):
word = word.lower()
def compute_score(word):
word = word.lower()
for letter in word:
def compute_score(word):
word = word.lower()
total = 0
for letter in word:
# add letter's score to total
return total
def compute_score(word):
scores = {"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}
word = word.lower()
total = 0
for letter in word:
# add letter's score to total
return total
def compute_score(word):
scores = {"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}
word = word.lower()
total = 0
for letter in word:
if letter in scores:
total = total + scores[letter]
else:
total = total + 1
return total
def get_input():
word = input("Enter a single word: ")
while not word.isalpha():
print("Error! Invalid Input!")
word = input("Enter a single word: ")
return word
def compute_score(word):
scores = {"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}
word = word.lower()
total = 0
for letter in word:
if letter in scores:
total = total + scores[letter]
else:
total = total + 1
return total
def main():
word = get_input()
print(compute_score(word))
main()