8. Your own while/else


#1




Oops, try again. Your code looks a bit off. Check the Hint if you need help! Your code threw the following error: invalid syntax (python, line 10)


I expect the "if" to work but for some reason it just keeps saying "invalid syntax"... Weird since it never happened before. Does anyone know what may be causing this? I checked the examples to see if the alignment of the code may be false but I think it's correct.


Replace this line with your code.
while guesses_left > 0:
    guess = int(raw_input("Your guess: ")
    if guess == random_number:
        print "You win!"
    break
    
else:
    print "You lose."
    guesses_left += 1


#2

@aaron.stypa ,

Are all the parentheses closed?

What condition are you providing to terminate the while loop, and how will that condition be met?


#3

Thank you very much, that pretty much solved the whole thing. :slight_smile:


#4