I need you to format your code properly, otherwise I cannot see your exact mistakes.
My best guess is that you fail to understand the philosophy of the while loop.
You don't need an if statement to exit the while loop if guesses are equal to 0. This will happen because that's how the while loop works. It is executed while the statement following it is True. When it's False, it "brakes". Now, guesses_left, will inevitably end up equal to 0, since you are also taking 1 out of guesses_left each time the loop executes.
So, get rid of the if guesses_left == 0.
Instead, add an else statement that executes when while doesnt like so:
print "You lose"
Another error you made is subtracting 1 from guesses_left right before you check if the answer given by the user is correct. I'll explain where it should go later on...
And, why would you set the guesses_left to 0 afterwards? Just brake the loop, when you brake a loop, the else statement after it does not execute, so you'll be fine.
Also, HUUUGE logical error. What happens if the user is wrong? You should add an else statement, under the while, under the if(but not nested under the if) where you will type guesses_left -= 1
Then, and only then, will the program subtract 1 from the guesses_left
How the whole code should look:
from random import randint
# Generates a number from 1 through 10 inclusive
random_number = randint(1, 10)
guesses_left = 3
# Start your game!
while guesses_left > 0:
guess = int(raw_input("Enter guess: "))
if guess == random_number:
print "You win!"
guesses_left -= 1
print "You lose"
IMPORTANT: Your code looks real bad, almost like you jumped from the first chapter to this one, it has too many logic and syntax errors, while the whole lesson takes you by the hand and shows you everything. Consider revising.