When reassigning max and min the author’s code uses min =guess; and max = guess;
This is logically incorrect. If guess were the correct number, the user would have pressed enter not Up Arrow or Down Arrow. The correct assignment if the user selects Up Arrow is min = guess +1;
In a similar manner, if the user presses the Down Arrow then max = guess - 1;
Not only does the above correct the logic error, it also makes the code work without the very ugly kluge of max=max +1 at the top of the code.