Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Guessing Game
- # Guessing function
- def guess(max, min):
- gotit = False
- 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:
- gotit = True
- return max, min, middle, gotit
- # Start
- max = 101
- min = 0
- tries = 0
- guessed = False
- print("Think of a number between 1 and 100")
- # Guess
- while (guessed == False):
- max, min, number, guessed = guess(max, min)
- tries +=1
- # End
- print("Your number is {}, it took me {} guess".format(number, tries))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement