Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have an issue with the following program: #importing the time module import time #welcoming the user name = raw_input(What is your name? ) print

I have an issue with the following program:

#importing the time module import time

#welcoming the user name = raw_input("What is your name? ")

print ("Hello, " + name, "Time to play hangman!")

print ("")

#wait for 1 second time.sleep(1)

print ("Start guessing...") time.sleep(0.5)

#here we set the secret word = "secret"

#creates an variable with an empty value guesses = ''

#determine the number of turns turns = 10

# Create a while loop

#check if the turns are more than zero while turns > 0:

# make a counter that starts with zero failed = 0

# for every character in secret_word for char in word:

# see if the character is in the players guess if char in guesses: # print then out the character print (char)

else: # if not found, print a dash print ("_"), # and increase the failed counter with one failed += 1

# if failed is equal to zero

# print You Won if failed == 0: print ("You won!")

# exit the script break

print

# ask the user go guess a character guess = raw_input("guess a character:")

# set the players guess to guesses guesses += guess

# if the guess is not found in the secret word if guess not in word: # turns counter decreases with 1 (now 9) turns -= 1 # print wrong print ("Wrong") # how many turns are left print ("You have", + turns, 'more guesses') # if the turns are equal to zero if turns == 0: # print "You Lose" print ("You Lose")

This is for a game of hangman. An error occurs saying that "raw_input" is not defined. I'm not sure how to fix this exactly. I thought it was already defined. How do I fix this?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

More Books

Students also viewed these Databases questions

Question

Describe how to train managers to coach employees. page 404

Answered: 1 week ago

Question

Discuss the steps in the development planning process. page 381

Answered: 1 week ago