low=1
high=1000
answer=int(input(f"ENTER A NUMBER BETWEEN {low} AND {high}: "))
guess=(high//2)
guesses=1
while guess!=answer:
print(f"CPU guess is {guess}.")
if guess>answer:
high=guess
else:
low=guess
guess=((high+low)//2)
guesses+=1
else:
print(f"CPU got it right in {guesses} guesses.")
When I enter 1000 as the answer the code crashes and goes on printing 999 and never stops, it happens just when we enter the high* value as the answer.