Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Guessing Game
- max = 100
- min = 0
- def guess(max, min, count):
- middle = int((max + min)/2)
- answer = input("Is your number [H]igher, [L]ower or the [S]ame as {}".format(middle)).upper()
- if answer == "H":
- min = middle
- return(max, min)
- elif answer == "L":
- max = middle
- return(max, min)
- else:
- print("Your number is", middle, "it took me",count," guess".format(middle))
- quit()
- print("Think of a number between 1 and 100")
- count =0
- while True:
- count = count + 1
- max, min = guess(max, min, count)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement