A way to accomplish that is with a do...while loop. You can first ask the user how many guesses he want and then execute the do block as many times as the guesses.