Stuck


#1



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!"
        break 
    guesses_left-=1

else:
     print "you lose"


INSTRUCTIONS
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


#2

Missing closing parenthesis on int().


#3

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


#4

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