Your own while else


#1

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("Your guess: ")
if guess==random_number:
print "You win!"
break
guesses_left=guesses_left-1

else:
print "You lose."

if guess==random_number:
i kept on having a syntex problem on this line.
can i get some advice?


#2

The line above isn't finished, it doesn't make sense to start another line - so it's a syntax error


#3

Did you ever figure this one out? I'm getting the exact same error as you were.


#4

in your code: guess = int(raw_input("Your guess:") --> here should come another bracket, unless it won't work, because the code isn't finished


#5

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