I am working on learning Python out of a book called Python Programming for the Absolute Beginner. Right now I am working on a challenge at the end of one of the chapters. During the chapter i was walked through the production of a word jumble game. At the end I am asked to add hints for each word and add a scoring system to reward the player for each word he guesses without having to use the hint. im not really sure the best way to go about this. Any suggestions and tips would be greatly appreciated!
here is the code for the game:
thank you for your time and help!
here is the code for the game:
Code:
# Word Jumble
#
# The computer picks a random word then "jumbles" it
# The player has to guess the original word
import random
# create a sequence of words to choose from
WORDS = ("python", "jumble", "easy", "difficult", "answer", "xylophone",
"anion", "cation", "polymorphasis", "stipulation", "antecedant")
# pick one word randomly from the sequence
word = random.choice(WORDS)
# create a variable to use later to see if the guess is correct
correct = word
# create a jumbled version of the word
jumble =""
while word:
position = random.randrange(len(word))
jumble += word[position]
word = word[: position] + word[(position + 1):]
# start the game
print \
"""
Welcome to Word Jumble!
Unscramble the letters to make a word.
(Press the enter key at the prompt to quit.)
"""
print "The jumble is:", jumble
guess = raw_input("\nYour guess: ")
guess = guess.lower()
while (guess != correct) and (guess != ""):
print "Sorry, thats not it."
guess = raw_input("Your guess: ")
guess = guess.lower()
if guess == correct:
print "That's it! You guessed it!\n"
print "Thanks for playing"
raw_input("\n\nPress the enter key to exit.")
thank you for your time and help!
Comment