Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print "Choose a number between 1 and 100000"
- won = False
- guesses = 0
- l = 0
- h = 100000
- while not won:
- guess = (h+l)/2
- guesses += 1
- print "Guess:",guess
- p = False
- while not p:
- p = True
- v = str(raw_input("Is my guess high, low, or correct (h/l/c): "))
- if v[0] == 'h':
- h = guess
- elif v[0] == 'l':
- l = guess
- elif v[0] == 'c':
- won = True
- else:
- print "Enter h, l, or c please"
- p = False
- print "I won in",guesses,"guesses"
Advertisement
Add Comment
Please, Sign In to add comment