Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Number guesser
#!/usr/bin/env python
lower, upper = 1, 100
print "Guess a number between %s and %s (inclusive)." % (lower, upper)
while lower < upper:
mid = (lower + upper) / 2
guess = raw_input("Is your number higher than %s? (y/n): " % (mid))
if guess == 'y':
lower = mid + 1
else:
upper = mid
print "Your number is %s!" % (lower)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.