while loops if guess secret_numprint'higher ' -num_guesses'guesses left \ 'elif guess secret_numprint'lower ' -num_guesses'guesses left \ 'elseprint'you got it'finallyit would be nice to have message for the player if they run out of turns when they run out of turnsthe while loop will stop looping and program control will shift to whatever comes outside of the loop at this point we can print the messagebut we only want to do so if the reason that the loop stopped is because of the player running out of turns and not because they guessed correctly we can accomplish this with an if statement after the loop this is shown below along with the rest of the completed program from random import randint secret_num randint( , num_guesses guess while guess !secret_num and num_guesses < guess eval(input'enter your guess ( - )')num_guesses num_guesses if guess secret_numprint'higher ' -num_guesses'guesses left \ 'elif guess secret_numprint'lower ' -num_guesses'guesses left \ 'elseprint'you got it'if num_guesses== and guess !secret_numprint'you lose the correct number is 'secret_numhere is an alternative solution using for/break loopfrom random import randint secret_num randint( , for num_guesses in range( )guess eval(input'enter your guess ( - )')if guess secret_numprint'higher ' -num_guesses'guesses left \ 'elif guess secret_numprint'lower ' -num_guesses'guesses left \ 'elseprint'you got it'break elseprint'you lose the correct number is 'secret_num