public
Created

/r/dailyprogrammer

  • Download Gist
challenge1-2.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
from random import randint
from sys import exit
 
def guessing_game(min, max):
old_min, old_max = min, max
guessing, ia_guess = True, (min+max)/2
print("Pick a number between {0} & {1}".format(min, max))
while guessing:
guess = input("Is your number %d ? (y)es, (p)lus, (m)inus : " % ia_guess)
if guess == "y":
break
if guess == "p":
old_min = ia_guess+1
if guess == "m":
old_max = ia_guess-1
try:
ia_guess = randint(old_min, old_max)
except ValueError:
print("bad game")
exit()
print("good game")
guessing_game(1, 100)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.