Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- lower_bound = 0
- upper_bound = 100
- guess = int((upper_bound + lower_bound) / 2)
- secret_number = ""
- answer = ""
- print("Please think of a number between", lower_bound, "and", upper_bound)
- print("Is your secret number", guess, "?")
- while answer != "c":
- answer = input("Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly.")
- if answer == "h":
- upper_bound = guess
- guess = int((upper_bound + lower_bound) / 2)
- print("Is your secret number", guess, "?")
- elif answer == "l":
- lower_bound = guess
- guess = int((upper_bound + lower_bound) / 2)
- print("Is your secret number", guess, "?")
- elif answer == "c":
- print("Game over. Your secret number was:", guess)
- else:
- print("Sorry, I did not understand your input")
- print("Is your secret number", guess, "?")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement