1. import math
  2. user = 0;
  3. result = 50;
  4. num = 1;
  5. print ("Type 'h' for higher and 'l' for lower and 'r' if I'm right");
  6. print ("I'm ready to play!");
  7. while 1 == 1:
  8.  
  9. print (result);
  10. user = input("Higher (h), Lower (l) or Right (r)?");
  11. if user == "h":
  12. result = math.ceil(result * (50 / num / 100 + 1));
  13. elif user == "l":
  14. result = math.floor(result * (1 - 50 / num / 100));
  15. elif user == "r":
  16. break;
  17. num = num + 1;
  18. print ("Number found in %d tries, not bad!" %(num));