import random
to_guess = random.randint(1, 1000)
count = 0
guess = 0
while guess != to_guess:
guess = int(input("Guess a number between 1 and 1000? "))
while guess < 1 or guess > 1000:
guess = int(input("Whoops, guess a number between 1 and 1000? "))
count += 1
if guess > to_guess:
print("Your guess is too high! Try a lower number.")
elif guess < to_guess:
print("Your guess is too low!. Try a higher number.")
print("You got it! The number is " + str(to_guess)+" and you got it in " + str(count) + " guesses!")
I hope this helps!