Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

nafiz hassan
11,482 PointsUnexpected Syntax Error(except)
Getting a syntax error at line 18, couldn't figure out why. run the script a couple of times
import random
def game():
# generate a random number between 1 and 10
secret_num = random.randint(1, 10)
guesses= []
while len(guesses) < 5:
try:
# get a number guess from the player
guess = int(input("Guess a number between 1 and 10: ")
except ValueError: <line 18>
print ("{} isn't a number!".format(guess))
else:
# compare guess to secret number
if guess == secret_num:
print ("You get it! My number was {}".format(secret.num))
break
else:
print ("That's not it!")
guesses.append(guess)
# print hit/miss
game()
[MOD: added ```python formatting -cf]
2 Answers

Abdishakur Hassan
3,585 PointsYou have this thing in your code next to exceptValueError <line 18> . Remove that and see if it works. And one More paranthesis is missimg before that in Guess=

nafiz hassan
11,482 PointsThanks guys... missed parenthesis was the issue now its resolved and "<line 18>" was for the forum
Christopher Janke
11,054 PointsChristopher Janke
11,054 Pointsguess = int(input("Guess a number between 1 and 10: ") is missing a )
is <line 18> in your code? Or are you just marking line 18 for the forum?