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

Alter the word jumble program with the following changes: A. Create functions B.

ID: 3628831 • Letter: A

Question

Alter the word jumble program with the following changes:
A. Create functions
B. New Features:
Add an advanced mode that jumbles the word and replaces 1/2 the letters with blanks.
Make each mode a function
Ask the user which mode they want to play.

from __future__ import print_function

#def input(string):
# return raw_input(string)

# 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.
(Press the enter key at the prompt to quit.)
"""
)
print("The jumble is:", jumble)

guess = input(" Your guess: ")
while guess != correct and guess != "":
print("Sorry, that's not it.")
guess = input("Your guess: ")

if guess == correct:
print("That's it! You guessed it! ")

print("Thanks for playing.")

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

Explanation / Answer

Dear.... play() method doesn't need to take guess as an argument. it just needs the_word.

Try with this code: import random
WORDS = ("python", "jumble", "easy", "difficult", "answer", "xylophone") def instructions():     print """ Welcome to Word Jumble! Unscramble the letters to make a word. (Press the enter key at the prompt to quit.) """ def random_word(word_list):     the_word = random.choice(word_list)         return the_word    def jumble(random_word):     word = random_word     jumble =""         while word:         position = random.randrange(len(word))                 jumble += word[position]         word = word[:position] + word[(position + 1):]                 print "jumble:", jumble         def play(the_word):         guess = raw_input(" Your guess: ")       guess = guess.lower()         while (guess != the_word) and (guess != ""):         print "jumble:", jumble         def play(the_word):         guess = raw_input(" Your guess: ")       guess = guess.lower()         while (guess != the_word) and (guess != ""):         print "Sorry, that's not it."         guess = raw_input("Your guess: ")         guess = guess.lower()           if guess == the_word:               print "That's it! You guessed it! "               print "Thanks for playing."               raw_input(" Press the enter key to exit.") def main():         instructions()     the_word = random_word(WORDS)     jumble(the_word)     play(the_word)       if __name__=='__main__': main()     instructions()     the_word = random_word(WORDS)     jumble(the_word)     play(the_word)       if __name__=='__main__': main()
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote