Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Guessing Game
- max = 101
- min = 0
- attempts = 1
- finished = False
- def Guessed_it(middle, attempts):
- print("Your number is {}".format(middle) + ". Number of guesses = " + str(attempts))
- def Guess(min, max,finished, attempts):
- while finished == 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
- attempts = attempts + 1
- elif answer == "L":
- max = middle
- attempts = attempts + 1
- elif answer == "S":
- Guessed_it(middle, attempts)
- finished = True
- return finished
- else:
- print("Invalid input, try again")
- print("Think of a number between 1 and 100")
- Guess(min,max,finished, attempts)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement