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

Jack Callaghan
Jack Callaghan
220 Points

Why is this showing as a syntax error?

I am trying to run the code shown in one of the python lessons and I have coded "if age <=6:" in line 9. When I go to run the code in the console I am getting a syntax error that says "File "/home/treehouse/workspace/hello.py", line 9 "if age<= 6:" SyntaxError: invalid syntax. I have gone over it a few times and it keeps coming up with it. I tried to attach a picture but I can't, can anyone tell me what I did wrong?

2 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,454 Points

Hey Jack, many times the syntax error is a result of an error on a previous line due to a missing closing quote or missing closing paren or bracket.

Good news: Python 3.10 (expected early October) will have improved error messaging!

Jack Callaghan
Jack Callaghan
220 Points

I have a picture of it but I can't figure out how to upload it into the question. It probably is that, I'll have to go back to take a look at it. Thank you!

Chris Freeman
Chris Freeman
Treehouse Moderator 68,454 Points

One way is to upload a to use Imgur.com then posts the link here using the format:

Images
Format:

![alt text](/path/to/img.jpg "Title")