Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics (2015) Number Game App Number Game Introduction

Umair iqbal
Umair iqbal
910 Points

why am i getting a syntax error?

import random

Generate a random number.

secret_num = random.randint(1, 10)

Tell the player if the guess is right or not.

while True: #Allow the player to guess. guess = int(input("What is your guess?:") if guess == secret_num: print("You got it {} was my secret number.".format(secret_num)) break elif guess > secret_num: print("My number is greater than {}.".format(guess)) continue else: print("My number is less than {}.".format(guess)) continue This is my code and i get a syntax error for the line with if guess == secret_num:

2 Answers

Dmitriy Ignatiev
PLUS
Dmitriy Ignatiev
Courses Plus Student 6,236 Points

Hi Umair,

it is because you miss ) in print ("My number is less than {}.".format(guess)

You need add ) to the end of above

print("My number is less than {}.".format(guess))

It will works

Cody Munster
Cody Munster
1,710 Points

You've Written:

guess = int(input("What is your guess?:")

Your First error is in the above i think. Try below:

guess = int(input("What is your guess?:"))