0

So i have this simple problem and I am not so sure what to do even after trying it for quite sometime.

combinations = ["rock","papers","scissors"]
ask = str(input("Do you want to play rock papers scissors?"))
while ask:
    if ask.lower() == "yes":
        print("ok")
        break
    elif ask.lower() == "no":
        print("okay :(")
        break
    else: 
        ask = input("So is it a yes or no ?!")
        break

my issue is that I am not so sure what to type such that my input user has to type either yes or no instead of typing something else. Additionally, when I tried to run the program, when I typed yes/no it jumped straight to the else statement instead of the if statement.. someone pls help :( (am just a noob programmer)

direct7
  • 3
  • 2
  • Does this answer your question? [Asking the user for input until they give a valid response](https://stackoverflow.com/questions/23294658/asking-the-user-for-input-until-they-give-a-valid-response) – quamrana Apr 11 '21 at 15:22

1 Answers1

1

I would remove the break in the else statement so that your program keeps looping until the user inputs yes or no.

combinations = ["rock","papers","scissors"]
ask = str(input("Do you want to play rock papers scissors?"))
while ask:
    if ask.lower() == "yes":
        print("ok")
        break
    elif ask.lower() == "no":
        print("okay :(")
        break
    else: 
        ask = input("So is it a yes or no ?!")
a_c1xyz
  • 71
  • 1
  • 4