Computer Science, asked by seenasureshkmd, 10 months ago

answer only if you know the answer and I want python program code​

Attachments:

Answers

Answered by akm26381
1

Answer:

Explanation:

n its simplest form you just ask the question, get the answer and process the answer, i.e.:

answer = input("Enter yes or no: ")

if answer == "yes":

   # Do this.

elif answer == "no":

   # Do that.

else:

   print("Please enter yes or no.")

You can go further and loop the question to allow for repeated incorrect input:

answer = None

while answer not in ("yes", "no"):

   answer = input("Enter yes or no: ")

   if answer == "yes":

        # Do this.

   elif answer == "no":

        # Do that.

   else:

    print("Please enter yes or no.")

Similar questions