I am writing my first python program (number guessing game) and I'm trying to ask if they are ready to play. If they answer yes, I want the program to continue. If they answer no, I want the program to either quit functioning, or asking them again if they are ready, with 'yes' being the only valid input that continues the code. If any other input is entered, I want the program to loop back on the question until 'yes' is input.
My original code was:
question = input("Do you want to try a guessing game?: [yes or no]")
if question != "yes":
exit("Okay, come back when you are ready!")
if question == "yes":
print("Great! Guess a number from 0-20")
and when I input anything except yes, the program does this:
I tried changing it to a while statement such as:
response = input("Do you want to try a guessing game?: [yes or no]")
while response:
if response =="yes":
print("Great, let's get started!")
break
elif response == "no":
print("Okay, Are you ready now?:")
else:
print("Sorry, please type 'yes' or 'no':")
break
However, when I input anything except yes, the statement "Okay, are you ready now?" repeats over and over.
I am looking for a way for the input of anything except 'yes' to loop back to the statement 'Okay, are you ready now?' and continue seeking input until the answer is 'yes'. I feel like I am so close but can't figure it out. Any help would be appreciated