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