#1

I’ve tried so many different variations here, but I don’t understand what’s wrong with my syntax there. Can anybody suggest a solution? I’m starting to lose my mind

#2

The below code works for me

The point is when the number guessed (guess) matches the random_number, the print statement ‘You Win!’ is executed loop and breaks ,if guess is wrong while loop gets executed till condition is met (guess_left = 3).

#3

I had the same problem… You are missing a closing parenthesis before the if-statement.

#4

why is the “else” statement aligned with the “while” statement rather than with the “if” statement?

#5
``````
# Generates a number from 1 through 10 inclusive
random_number = randint(1, 10)
print "All right, you wanna play Guess the Number?"
wanna_play = (raw_input("Wanna play? "))
print "I didn't really hear you, but I don't care."
print "I'm gonna choose one number between 1 and 10. You HAVE to guess."
guesses_left = 3
while guesses_left >= 1:
if guess == random_number:
print "You guessed right. You win, I guess."
break
else:
print "Wrong."
guesses_left -= 1
else:
print "Game over. You lose. Ha!"
``````

That worked for me.

#6
``````int(raw_input("Guess my number please: ")
``````

Looks like your input code is missing a parentheses at the end.

should be:

``int(raw_input("Guess my number please: "))``