Your own while / else help


#1




Console giving error : File "python", line 10
numm = random.randint(1, 6)
^
SyntaxError: invalid syntax

Codecademy giving error
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)


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: ")
    numm = random.randint(1, 6)
    if guess == numm:
        print("You win!")
        break
    else:
        print("You lose.")
        guesses_left = guesses_left - 1

Thanks to anyone that helps!


#3

Different error now, error:Oops, try again. Did you include an else for the while loop?


#4

you should have a while/else, you currently have an if/else


#5

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