''' Purpose: show a while statement ''' # set loop decision variable looking_for_a_yes_or_no = True # = this is assignment - we are telling python that this variable should # hold the value True # always want to initialize your while loop loop variables to True so you enter the loop counter = 0 while ( looking_for_a_yes_or_no == True ) : # repeat while looking # == this is comparison, we're checking if what is stored in the variable is True # is the == True necessary? no. looking_for_yes_or_no is a boolean variable, it only stores True or False # if we had while( looking_for_a_yes_or_no ) it would work the same # put the == True if that's what works best for you, typically does work best for intro coders!! # get cleaned up response reply = input( 'Enter (yes / no): ' ) # get some sort of input reply = reply.strip() # clean that up reply = reply.lower() # lowercase it so it is easier to check print(reply) counter = counter + 1 # check for valid response. if ( reply in [ 'yes', 'no' ] ) : # in is a keyword that will return True or False. # got one # break will get you out of the loop looking_for_a_yes_or_no = False #if True we change our loop variable because we are done looping # have to update the loop variable or we will be infinitely looping and no one wants to be infinitely looping elif ( counter == 10 ) : print( "You can't follow directions :(" ) break print( reply )