Question: Python I need to correct an error when the program runs and has nameError for if play _ again in yesList: , this should ask
Python
I need to correct an error when the program runs and has nameError for if playagain in yesList: this should ask number from user and inform user if too high or too low or if it matches the same number and then ask user if they want to play again, if yes play again generate a new random number and ask user to input a number again. If the answer is no then exit the game and say goodbye.
#Program asks for a number and if you get the number you win
import random
def hello:
printHello welcome to the Guessing Game!"
def goodbye:
printGoodbye thank you for playing!
def main:
number intinputPlease enter a number between to :
noList: liststrnonNNO
yesList: liststryesyY "YES"
hello
number intinputPlease enter a number between to :
numbertoguess random.randrange
while numbertoguess number:
if number numbertoguess:
printToo high"
break
elif number numbertoguess:
printToo low"
break
else:
printCongratulations you got the right number!"
break
printnumber
printnumbertoguess
playagain inputWould you like to play again? yn:
if playagain in yesList:
main
else:
goodbye
main
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
