Even when the jumble is solved correctly, the program prints the try again message. What am I missing.
Code:
# Led Zeppelin Word Jumble
# to utilize loops, strings and tupules
# Nathan Porter
# 10/03/2011
import random
# create a sequence of words to choose from
words = ("Robert Plant", "Jimmy Page", "John Bonham", "John Paul Jones",)
hints = {"Robert" : "The greatest voice in rock",
"Jimmy" : "Yardbird",
"Bonham" : "R.I.P. 25 September 1980",
"Jones" : "triquetra"}
word = random.choice(words)
hint = 'hint'
correct = word
word1 = word
count = 1
# create a jumbled version of the word
jumble =""
while word:
position = random.randrange(len(word))
jumble += word[position]
word = word[:position] + word[(position + 1):]
score = 0
# start the game
print(
"""
Welcome to Led Zeppelin Word Jumble!
Unscramble the letters to make a word.
Type 'hint' for help or just press Enter to give up
"""
)
print("\nThe jumble is:", jumble)
guess = input("Your guess:\n>>>")
guess = guess.lower()
if guess == "":
print ("You Lose!"),
elif guess == hint:
if word1 == 'Robert Plant':
print (hints,("Robert"))
elif word1 == 'Jimmy Page':
print (hints,("Jimmy"))
elif word1 == 'John Bonham':
print (hints,("Bonham"))
elif word1 == 'John Paul Jones':
print (hints,("Jones"))
while (guess != correct) and (guess != ""):
print ("Lots of people talk but few of them know...")
guess = input("Your guess:\n>>>")
guess = guess.lower()
if guess == correct:
print ("...and it only goes to show, you know!\n"),
print("Thanks for playing")
input("\n\nPress the enter key to exit.")
Comment