Python Forum
scrabble word game - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: scrabble word game (/thread-6193.html)



scrabble word game - atux_null - Nov-10-2017


i need to create scrabble game with the user to type the word and then calculate the value of this word. i have to use the following dictionary:
 score = {"A": 1, "C": 3, "B": 3, "E": 1, "D": 2, "G": 2, 
         "F": 4, "I": 1, "H": 4, "K": 5, "J": 8, "M": 3, 
         "L": 1, "O": 1, "N": 1, "Q": 10, "p": 3, "S": 1, 
         "R": 1, "U": 1, "t": 1, "W": 4, "V": 4, "Y": 4, 
         "X": 8, "Z": 10}
the program needs to run forever unless the user types q.the users types a word in capital case eg WATER and the program needs to print out WATER point eg 24
the words and the scores needs to get stored each in different dictionary.

Some guidance please?


RE: scrabble word game - Mekire - Nov-10-2017

As usual you will need to attempt the problem before we can help.
Use a while loop to make the program run until a certain input is given.
When given a word input iterate through its letters with a for loop and sum up the values from the dictionary.


RE: scrabble word game - atux_null - Nov-10-2017

something like that?

word = input("Please input the word or q to exit: ")

for letter in word:
    score = score + points[letter]
    
print(word,"has ", score, "points")
i am missing how to make it run endlessly and how to press to exit.


RE: scrabble word game - heiner55 - Nov-10-2017

while True:
  word = input("Please input the word or q to exit: ")
  if word == 'q':
      break

  #...
  #...
  #...

print("game over")



RE: scrabble word game - atux_null - Nov-10-2017

thanks a lot