Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- max = 100
- min = 0
- attempt=0
- print("Think of a number between 1 and 100")
- def guess():
- max = 100
- min = 0
- count=0
- 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
- elif answer == "L":
- max = middle
- else:
- print("Your number is {}, it took me 1 guess".format(middle))
- while min< max!=S:
- attempt=count+1
- max,min = guess(max,min)
- print("Your number is {}, it took me {} guesses".format(max,count))
- guess()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement