Give this a try:
from random import randint randomNum = randint(1,100) print('I am thinking of a number between 1 and 100.') for guessesTaken in range(1, 100): print('Take a guess.') guess = int(input()) if guess < randomNum: print('Your guess is too low.') elif guess > randomNum: print('Your guess is too high.') else: break if guess == randomNum: print('Good job! You guessed my number in ' + str(guessesTaken) + ' guesses!') else: print('Nope. The number I was thinking of was ' + str(randomNum))