I'm working on learning python, here is a simple program, I wrote:
def guesser(var, num1,possible):
if var == 'n':
cutoff = len(possible)/2
possible = possible[0:cutoff]
cutoff = possible[len(possible)/2]
#print possible
if (len(possible) == 1):
print "Your Number is:", possible
else:
var = raw_input("Is Your Number Bigger Than %s? (y/n): " %cutoff)
guesser(var, cutoff,possible)
elif var == 'y':
cutoff = len(possible)/2
possible = possible[cutoff:len(possible)]
cutoff = possible[len(possible)/2]
#print possible
#print cutoff
if (len(possible) == 1):
print "Your Number is:", possible
else:
var = raw_input("Is Your Number Bigger Than %s? (y/n): " %cutoff)
guesser(var, cutoff,possible)
else:
var = raw_input("Is Your Number Bigger Than 50? (y/n): ")
guesser(var, 50, possible)
possible = []
possible = range(1,101)
guesser('a', 50, possible)