Advertisement
scarygarey

functions

Jan 12th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. max = 100
  2. min = 0
  3. attempt=0
  4.  
  5. print("Think of a number between 1 and 100")
  6.  
  7. def guess():
  8. max = 100
  9. min = 0
  10. count=0
  11. middle=int(max-min/2)
  12. answer = input("Is your number [H]igher, [L]ower or the [S]ame as {}".format(middle)).upper()
  13. if answer == "H":
  14. min = middle
  15. elif answer == "L":
  16. max = middle
  17. else:
  18. print("Your number is {}, it took me 1 guess".format(middle))
  19.  
  20. while min< max!=S:
  21. attempt=count+1
  22. max,min = guess(max,min)
  23. print("Your number is {}, it took me {} guesses".format(max,count))
  24.  
  25. guess()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement