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 Types and Branching If, Else and Elif

I can not figure out why I am getting this Syntax error. Please help.

treehouse:~/workspace$ python
Python 3.6.4 (default, Apr 11 2019, 19:31:33)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.

python hello.py
File "<stdin>", line 1
python hello.py
^
SyntaxError: invalid syntax

This is my code up top:

first_name = input("What is your first name? ")
print("Hello,", first_name) if first_name == "Angie" : print (first_name, "is learning Python") print ("Have a great day {}!).format(first_name))

1 Answer

At the workspace prompt you can type python hello.py to run your program:

treehouse:~/workspace$ python hello.py 

At the python prompt type import hello for the same results

>>> import hello

You also need to fix your code. There should be a quotation mark after ! instead of a parenthesis

print ("Have a great day {}!".format(first_name))

Thanks for the help! I appreciate it. :)