C
Chad Everett
Hey guys,
I am back. Trying to expand on a program that was given in the book I am
studying.
No I am not a high school or college student. Doing this on my own. and
having way to much trouble
I am trying to add a hint section to a word jumble program.
I get a traceback error that the word in the jumble is not defined.
Can anyone help?
thanks,
import random
# create a sequence of words to choose from
WORDS = ("python", "easy")
# 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 variable to use for hint if needed
# create a jumbled version of the word
jumble =""
while word:
position = random.randrange(len(word))
jumble += word[position]
word = word[osition] + 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
print "If you need a hint type 'hint' and Hit enter."
guess = raw_input("\nYour guess: ")
guess = guess.lower()
while (guess != correct) and (guess != "")and (guess != hint): ##not sure
about this either##
print "Sorry, that's not it."
guess = raw_input("Your guess: ")
guess = guess.lower()
###I don"t lnow how to set up this part correct so that when they ask for
the hint it will give it to them###
while word == easy:
if guess == hint:
print "not hard but"
guess = raw_input("Your guess: ")
guess = guess.lower()
while word == python:
if guess == hint:
print "snake"
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.")
I am back. Trying to expand on a program that was given in the book I am
studying.
No I am not a high school or college student. Doing this on my own. and
having way to much trouble
I am trying to add a hint section to a word jumble program.
I get a traceback error that the word in the jumble is not defined.
Can anyone help?
thanks,
import random
# create a sequence of words to choose from
WORDS = ("python", "easy")
# 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 variable to use for hint if needed
# create a jumbled version of the word
jumble =""
while word:
position = random.randrange(len(word))
jumble += word[position]
word = word[osition] + 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
print "If you need a hint type 'hint' and Hit enter."
guess = raw_input("\nYour guess: ")
guess = guess.lower()
while (guess != correct) and (guess != "")and (guess != hint): ##not sure
about this either##
print "Sorry, that's not it."
guess = raw_input("Your guess: ")
guess = guess.lower()
###I don"t lnow how to set up this part correct so that when they ask for
the hint it will give it to them###
while word == easy:
if guess == hint:
print "not hard but"
guess = raw_input("Your guess: ")
guess = guess.lower()
while word == python:
if guess == hint:
print "snake"
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.")