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 (Retired) Ins & Outs String Concatenation

Name Syntax Error and Highlighting

When I type a variable, it doesn't highlight as show in the video, "I/O python" (The third one I believe). Also, "lumberjack.py" has a syntax error in the name apparently, but it always the last letter. For Ex: If I delete the "ack" in lumberjack.py, it says the error is the "j". If I delete the "j", it's "r". I don't know if this is a great way to state my problems, but it's all I could do. I'm probably just doing something wrong, so here's the string:

name = input('What's your name?' )

if name == "Ethan":

  print(name + ' Is a lumberjack, and he is okay! ')

else:

  print(name + 'sleeps all night. ')

Again, sorry if this is hard to understand. This happens even if I take someone's working code.

4 Answers

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

That code looks ok. What do you mean about the filename?

Thanks for replying Kenneth =D. The error occurs when I type in the Console: python lumberjack.py. It says there is a syntax error in the name. For Ex:

lumberjack.py

             ^
     Syntax Error
  or if I rename it to something like lumberj.py it says:

lumberj.py

      ^
 Syntax Error

I presume the arrow is pointing towards the name or filename because it always follows the last letter before the '.py' of the name. Again, sorry if this needs a better explanation.

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

Are you in the Python shell when you're trying to run this? Easiest way to tell is that your prompt will be >>> in the shell. If you are, run exit() and then try to run your script again.

I am in the python shell, thankfully. Let me try the exit command. Thanks!

Okay, that fixed it! Just some indention errors now, and I should be on my way! Thanks Kenneth, I'll let you know of any future troubles. Love our Python videos by the way ;).