Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to make adjustments to current Word Jumble code. I need to pair each word

ID: 3531400 • Letter: I

Question

I need to make adjustments to current Word Jumble code. I need to pair each word with a hint and player should see hint if they are stuck. Also, I need to add a scoring system that rewards players that solve jumble without hint. Below is current code. I need this to work in python 3.3 pleaseeee. Thanks!!


# Word Jumble
#
# The computer picks a random word and 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")
# 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.
Enter a guess, an X to give up, or type ? and press enter for a hint.
(Press the enter key at the prompt to quit.)
"""
)
print("The jumble is:", jumble)

guess = input(" Your guess: ")
1st = range(len(jumble))
hint_str = '_'*len(jumble)
while True:
guess = raw_input("Guess or '?' or 'X': ").lower()
if guess == correct:
print("That's it! You guessed it! ")
break
elif guess == '?':
i = random.choice(lst)
print correct [i], ("is the", i+1, "letter")
score += 1
elif guess == 'x':
print ("Sorry you gave up!")
break
else:

print("Sorry, that's not it.")


print("Thanks for playing.")

input(" Press the enter key to exit.")

Explanation / Answer

# 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") # 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):] # sets score to zero score = 0 # start the game print """ Welcome to Word Jumble! Unscramble the letters to make a word. Enter a guess, an X to give up, or type ? and press enter for a hint. (Press the enter key at the prompt to quit.) Try to get the lowest score possible. For each hint, you gain a point. See if you can win with no points! """ print "The jumble is:", jumble guess = raw_input(" Your guess: ") guess = guess.lower() lst = range(len(jumble)) hint_str = '_'*len(jumble) while True: if guess == correct: print "That's it! You guessed it! Your score is", score raw_input(" Press the enter key to exit.") break guess = raw_input("Guess or '?' or 'X': ").lower() elif guess == '?': i = random.choice(lst) print correct[i], "is the", i+1, "letter." score += 1 guess = raw_input("Guess or '?' or 'X': ").lower() elif guess == 'x': print "Sorry you gave up!" break else: print "Sorry, thats not it. Try again." guess = raw_input("Guess or '?' or 'X': ").lower()