''' Purpose: play guess a number ''' # specify max number n = 10000 # start the game print( 'Think of a number from 0 to', n ) # ??? # for i in range(1, 100001): # # print("Is it", i) # # prompt = "Is it " + str( i ) + " : " # reply = input( prompt ) # reply = reply.strip().lower() # # if (reply == 'yes' ): # print( "I got it " ) # So what are we trying to do? Guess the number right? # So we want to stop when we reach the number akaaa we wanna set # whatever our boolean is to False when we find it to stop the while loop. looking_for_number = True next_guess = 1 while ( looking_for_number ): prompt = "Is it " + str( next_guess ) + " : " reply = input( prompt ) reply = reply.lower().strip() if ( reply == "yes" ): print( "I got it! ") looking_for_number = False # We set this equal to False since we # got a yes from the user, meaning we got their number, # and this stops the while loop and makes it stop looking. # Since the else statement occurs when we HAVE NOT found the number, # we don't stop the loop so we don't set # looking_for_number = False here because we wanna keep going. # I just wanna point out like be superrrr careful where you # set the test expression (looking_for_number) to be False # because remember the while loop keeps repeating until # it gets to False and if you reach False at the wrong time # the loop will stop when you don't want it to and you'll be sad. else: next_guess = next_guess + 1 # We have to increment next guess # so that the value of i changes each time we guess as we # go higher and higher up