''' Purpose: repeatedly prompt the user until they reply with a yes or no. The case of the letters do not matter. ''' looking_for_a_yes_or_no = True # Generally start off the test expression as True so you can # set it to False later on when you get what you want and # you wanna be done with the while loop. :) # This variable is just a variable that stores the value of a variable. # We set it to True so that we can set it to false later once # we find what we're looking for! Think of it kindaaa like a light switch. # Turning the light switch on while you look for something and then off # when you find it and finish and stop looking. while ( looking_for_a_yes_or_no == True ) : # Sooo if you do it this way # there's no need for line 6. reply = input( 'Enter (yes / no): ' ) reply = reply.lower().strip() # When you call multiple string functions on the same stirng, make sure that # all your functions are returning strings when you call it on them. # reply.lower() returns a string so we can then call .strip() on that # string. if ( reply in [ 'yes', 'no' ]): # if looking_for_a_yes_or_no = False # So remember that indentation is whenever an action is part of a # larger for or if or while statement. # So everything indented under the while is done for each time we # run through the while loop. # So in this example, in the while loop, what are we doing? # Getting an input, stripping/lowercaseing it, and then checking to see # if its yes or no and then setting the looking_for_a_yes_or_no variable # to be false to signify heyyy we found it so stop the while loop ( # by setting the variable to False) because it's not True anymore! So it stops. # ;we don't have to repeat this process in the while loop again. print( reply )