Guess My Number, Classic Edition
Mixing Python 2 and 3

The program is correct in neither Python 2 nor Python 3.

Your program fails to run at all in Python 3, due to the lack of parentheses when calling

print "You failed to guess in time!"


Also, the raw_input() function does not exist in Python 3.

On the other hand, it's not quite correct under Python 2 either.  These print statements

print("You guessed it! The number was", the_number)
print("And it only took you", tries, "tries!\n")


would be interpreted as requests to print tuples… complete with parentheses and commas.

Initialization

The number of allowed guesses, 5, is buried in the middle of your program, and should be defined in an obvious place near the top.

The bounds, 1 and 100, are each hard-coded twice.  That is a maintenance pitfall, should you ever need to change the upper bound.  Again, these special numbers should be defined just once in an obvious place.

Loop

The "Take a guess" prompting statement is written twice.  It should be moved inside the loop, at the top of the loop.

@MasayukiFujita and @MathiasPanda have the right idea, I think, to use the count rather than the correctness as the loop condition.  I would go a step further and suggest that counting loops in Python would be more idiomatically written using for counter in range(…).

To distinguish between the winning and losing condition without using a boolean variable or retesting the correctness of the guess, you can take advantage of an obscure Python language feature: an else clause on a loop.  The else clause is executed only when the loop terminates "naturally", rather than due to a break.

Newline management

You'll have a better time printing nice output if you make a habit of always putting your newlines at the end of print statements.

Suggested solution

Here is a program that works in both Python 2 and Python 3.

import random

BOUNDS = (1, 100)
TRIES_ALLOWED = 5

the_number = random.randint(*BOUNDS)

print("\tWelcome to 'Guess My Number'!\n")
print("I'm thinking of a number between %d and %d." % BOUNDS)
print("Try to guess it in as few attempts as possible.\n")

for tries in range(TRIES_ALLOWED):
    guess = int(input("Take a guess: "))

    if guess &gt; the_number:
        print("Lower...")
    elif guess &lt; the_number:
        print("Higher...")
    else:
        print("You guessed it! The number was %d" % (the_number))
        print("And it only took you %d tries!\n\n" % (tries + 1))
        break
else:
    print("You failed to guess in time!\n\n")

# Admittedly a contorted way to write a statement that works in both Python 2 and 3...
try:
    input("Press the enter key to exit.")
except:
    pass