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 (2015) Logic in Python Fully Functional

Syntax error although i've copied each line correctly.

Is there something wrong with my code? or is my console configured properly?

def hows_the_parrot(): print("He's pining for the fjords!")

hows_the_parrot()

ERROR MESSAGE SyntaxError: invalid syntax

python functions.py
File "<stdin>", line 1
python functions.py
^

2 Answers

Anish Walawalkar
Anish Walawalkar
8,534 Points

Hey Clyon, there is absolutely nothing wrong with your python syntax, however you are already in the python terminal as indicated by >>>

Now, you can do one of two things:

  1. Exit the python terminal by using the command exit() and then running python functions.py in the regular bash terminal
  2. Remain in the python terminal and type the following command from functions import hows_the_parrot, this imports the hows_the_parrot function. now you can call it with hows_the_parrot()

Both of these options will produce the desired outcome

Thanks so much! it worked.