Guess My Number
import random
the_number = random.randrange(100) + 1
guess = int(raw_input("Take a guess: "))
tries = 1
while (guess != the_number):
if (guess > the_number):
print "Lower..."
else:
print "Higher..."
guess = int(raw_input("Take a guess: "))
tries += 1
print "You guessed it! The number was", the_number
print "And it only took you", tries, "tries!\n"
raw_input("\n\nPress the enter key to exit.")
Related examples in the same category