Jul-24-2017, 02:22 PM
Yeah you are right, and I updated my min to guess when it's smaller than answer, and max to guess when larger than answer. But now I have trouble updating the other half, when guess is smaller than answer, then the max should be max of the previous max; when guess is larger than answer, min should be min of the previous min. The below is what I have now
import random random.randint(1,99) answer = int(input()) maximum=100 minimum=1 print(minimum,"<?<",maximum) while True: guess = int(input()) if guess ==answer: print("bingo answer is",answer) break elif guess<answer: print("wrong answer, guess larger") new_max=maximum new_min=guess print(new_min,"<?<",new_max) elif answer<guess: new_max=guess new_min=minimum print(new_min,"<?<",new_max) print("wrong answer, guess smaller")