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

number_game2.py

When I try to run the game it points to line 11 and says there's a syntax error if guess == secret_num: with an arrow under the colon.

https://w.trhou.se/fv3l7tj97k

2 Answers

Hey Rico! The reason its throwing a syntax error on line 11 is because you havent properly closed your print statement on line 9 (You should add another ")" to the end). You have more issues in your code, but ill leave you to figure them out. Please feel free to ask again if you cant solve them tho. Happy coding!

Thanks for the help, I might just start from scratch but what I don't know is how to have the computer give an input. Sorry you had to see that mess of a program.

Hey Rico! I am assuming that what you mean is how to have the computers guess, be displayed in the console. You could simply use the print statement for this, and format the guess into that print statement. For instance:

import random
computer_guess = random.randint(1, 10)

after the computer has sellected a random number between 1 and 10, you could print that guess to the console like this:

print("I think your number is {}".format(computer_guess))

That aside i assume your trying to create a program in which the computer trys to guess a players number? I wouldent say you have to completely restart, but i strongly suggest you take another look at the code on line 9. Here you are trying to say that guess = a print?? Shouldent the guess be equal a random number between 1 and 10?