Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics Meet Python Variables

Hello, when I type a code print('Hello',', first_name) as in the video I get an error in the console syntax is invalid

SyntaxError: EOL while scanning string literal points to first_name.... also I am not able to take screen shots of the workspace. Screenshots always empty

Hi I think you have a trailing apostrophe and comma there. Should read as follows:

print('Hello', first_name)

The string followed by the variable reference.

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 67,763 Points

When Python sees a single or double quotation mark while parsing a line of code, it continues to scan to find the matching closing mark.

print('Hello',', first_name)
      ^ start of first string
            ^ end of first string
              ^ start of second string

The parser thinks the second string is “, first_name)” but cannot find the closing single quotation mark which raises the syntax error. The automatic color highlighting shows the runaway string.