from random import randint

# Generates a number from 1 through 10 inclusive
random_number = randint(1, 10)

guesses_left = 3

while 0<guesses_left:
    guess=int(raw_input("Your guess:")
    if guess ==random_number:
        print "You win!"

     print "you lose"

Use a while loop to let the user keep guessing so long as guesses_left is greater than zero.
Ask the user for their guess, just like the second example above.
If they guess correctly, print 'You win!' and break.
Decrement guesses_left by one.
Use an else: case after your while loop to print You lose..

PROBLEM----> invalid syntax, your code looks a bit off


Missing closing parenthesis on int().


o thanks! i always miss the simplest things :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.