# L-15 MCS 275 Mon 15 Feb 2010 : findsecret.py from random import randint def main(): """ Generates a secret number between 0 and 1000 for the user to guess. By the feedback given to the user, ten guesses should suffice. """ secret = randint(0,1000) count = 0 while True: count = count + 1 guess = input('guess number in [0,1000] : ') if secret == guess: break elif secret > guess: print 'your guess is too low' else: print 'your guess is too high' print 'found %d after %d guesses' % (secret,count) main()