Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
scrabble word game
#1

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?
Reply
#2
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.
Reply
#3
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.
Reply
#4
while True:
  word = input("Please input the word or q to exit: ")
  if word == 'q':
      break

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

print("game over")
Reply
#5
thanks a lot
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Need some help creating a word game wthiierry 4 2,402 Nov-01-2022, 12:29 PM
Last Post: perfringo
  Scramble word game Zatoichi 9 8,410 Sep-20-2021, 03:47 PM
Last Post: jefsummers
  Word based Game of 21 DatNerdKid 2 75,772 Aug-24-2018, 03:25 PM
Last Post: DuaneJack

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020