I try to write a completely separate script based on what I just learned, to try and make sure I understand it. In the following code, I just cannot understand why, when guessing the correct random number, it never reaches my ELSE: statement, printing that the guess was correct? I know the answer has to be simple, but I am just confused.
from sys import exit
import random
print "Guess the number between 1 thru 10"
print "You have 3 tries"
guess = raw_input("Enter a guess-->")
tries = 3
random_number = random.randrange(1,10)
while tries > 1 and guess != random_number:
print "That's not the number, try again!"
print "Tries remaining:", tries - 1
guess = raw_input("Next guess?-->")
tries = tries - 1
if guess != random_number:
print "Sorry, you lose!"
print "The number was", random_number
exit(0)
else:
print "You guessed it!"