Advertisement
Guest User

Untitled

a guest
Jan 21st, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. ## Guessing Game
  2. # Tony Goodhew
  3. maxx = 101
  4. minn = 0
  5. tries = 0
  6. ans = "D" # Dummy
  7. print("Think of a number between 1 and 100")
  8.  
  9. def ans(hi,lo,guess):
  10. guess = guess + 1
  11. middle = int((hi + lo)/2)
  12. answer = input("Is your number [H]igher, [L]ower or the [S]ame as {} : ".format(middle)).upper()
  13. if answer == "H":
  14. lo = middle
  15. elif answer == "L":
  16. hi = middle
  17. else:
  18. return hi, lo, guess, answer, middle
  19.  
  20. while ans != "S":
  21.  
  22. maxx, minn, tries, ans, result = ans(maxx, minn, tries) # Error line !!!!!!!!!!!!!!
  23. if answer == "S":
  24. print("Your number is ", result)
  25. print("It took me ", tries, " guesses")
  26. quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement