# Loop 8/19

#1

My codes works but this is the messages that I'm getting:

``````Oops, try again.
Did you include an else for the while loop?``````

Can I have a few fresh eyes to see what i dont see?

from random import randint

# Generates a number from 1 through 10 inclusive

random_number = randint(1, 10)

guesses_left = 3

while guesses_left > 0:
if guess != random_number:
print "You lose"
else:
print "You Win!"
break
guesses_left -=1

#2

I figured it out:

from random import randint

# Generates a number from 1 through 10 inclusive

random_number = randint(1, 10)

guesses_left = 3

while guesses_left > 0:
print guesses_left
guesses_left -=1
if guesses_left == random_number:
print "You Win!"
break
else:
print "You lose!"

#3

This code works.

```from random import randint

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

guesses_left = 3
while guesses_left > 0:
if guess == random_number:
print "You win!"
break
guesses_left -= 1
else:
print "You lose..."```

#4

Hi there could you spot the error with this code I cant? from random import randint

guesses_left = 3
while guesses_left > 0:
random_number = random.randint(1, 10)
print random_number
if guess == random_number:
print "You win!"
break
guesses_left -=1
else:
print 'You lose'

gives the following output:
File "python", line 4
guesses_left = 3
^
SyntaxError: invalid syntax

#5

don't worry I fixed it. was missing closing brackets at top guess = ..... and it also needed me to delete random which I added randomly and realised the error so I removed, the whole game is random though