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!

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 Refinement

I have literally typed every single thing the instructor said. I have double-checked, triple-checked, quadruple-checked.

I have literally put everything in my workspace exactly as it was typed by the instructor. I have double-checked, triple-checked, quadruple-checked, quintuple-checked, you name it. I have checked so many times to see if something I typed in the workspace is any different than what the instructor put in on his video demonstration, and everything I typed in my workspace is completely identical to what the instructor had typed. This is beyond any doubt the most frustrated I have ever been with coding. There is literally nothing wrong, but yet it keeps saying there is a syntax error and it always, ALWAYS, points to the letter 'n' on the play_again I typed.

There is absolutely nothing wrong with any of my syntax and I want a better way to prove it!

Your on a very old python course, try checking out the updated python basics track

28,556 Points

Can you provide a snapshot of your workspace? That way we can take a look at your code, otherwise there is absolutely no way for us to identify the issue you are dealing with. Python is a pretty strict language, not only does the syntax need to be correct, but the indentation (horizontal spacing) also needs to be correct for the code to be interpreted correctly.

To make a snapshot you have to click on the button in the top-right of your workspace that somewhat resembles a camera. You can see a video of a snapshot being taken at the 1:35 mark in this video.

Once you have generated a snapshot URL just post it as a reply to this comment and I'll take a look at it.

Thank you andren! I have taken a snapshot. However, now I am unable to use the Console on the workspace to show the error that keeps popping up. But here is my code: https://w.trhou.se/uiovnon4sh

Go to number_game.py

2 Answers

28,556 Points

The issue is that you are missing a closing parenthesis on line 22:

print("You didn't get it! My number was {}".format(secret_num)

You are calling two functions (print and format) but only close one of them. If you add an additional closing parenthesis at the end of the line like this:

print("You didn't get it! My number was {}".format(secret_num))

Then your code should work. The reason why Python complains about line 23 is that it still thinks you are defining arguments for the function call that you didn't close on line 22.

It's pretty common that an error that is identified on one line is actually caused by an issue on the line right above it.

Thank you so much for finding the problem and pointing this out to me. I can't believe I missed that. I checked my code so much. How the heck did I not see it? I guess it helped having a second set of eyes on it. Thank you for finding this.

28,556 Points

Yeah "Code blindness" is definitively a thing, especially when you have spent a long time writing and glancing at a section of code. That's partly why code reviews by other developers tend to be mandatory in a lot of companies.

Though it's also partly a matter of experience. Once you have coded a while you'll notice that certain types of typos tend to occur more frequently than others. And once you start to identify them it becomes easier to notice them while analyzing your code. Missing a closing parenthesis in situations where two closing parenthesis are needed in a row is a pretty common typo. Which is why I managed to spot it so quickly.

I see. Thank you! It would have been nice if the error it kept pointing out to me was the missing parentheses instead of the letter 'n' on play_again, but I guess the workspace didn't truly understand what I was trying to do and I didn't realize that I missed that parentheses. Thank you so much for your help. You have no idea how much this dragged me down. I took a bunch of time off from coding just because of it. I honestly saw nothing wrong. I can't believe I missed that, but thank you so much for finding it for me. I'm really happy to finally move forward from this task.