Advertisement
superpawko

Untitled

Sep 26th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. low, high = 0, 100
  2. ans = abs(high - low) // 2
  3. check=''
  4. print("Please think of a number between 0 and 100!")
  5.  
  6. while True:
  7. print("Is your secret number " + str(ans) + "?")
  8. check = 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. ")
  9. if check == 'c':
  10. print("Game over. Your secret number was: " + str(ans))
  11. break
  12. elif check == 'h':
  13. high = ans
  14. elif check == 'l':
  15. low = ans
  16. else:
  17. print("Sorry, I did not understand your input.")
  18. ans = (high + low) // 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement