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) Shopping List App Shopping List Introduction

Joel Price
Joel Price
13,711 Points

When testing code in the console I get SyntaxError even though I've written it just like is on the screen.

For example, I've created a shopping_list.py file in Workspace and it's in the same place as the instructors. However, when I point to it in the console I just get a syntax error. For whatever reason, I can't Copy/Paste it, but it looks like this.

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

I can't figure out why the error is pointing to that location. The file has been saved to the same location as in the video. the string I'm using is the same as in the video, etc.

Any help is appreciated.

Joel Price
Joel Price
13,711 Points

the '^' is actually under the t in python shopping_list.py

1 Answer

Steven Parker
Steven Parker
229,744 Points

It looks like you are already running Python when you give this command.

The command you are giving is intended to run a python program from the workspace system console, but based on the ">>>" prompt you show above, it appears that you are already running Python when you type it.

First exit Python (type "exit()") to get back to your system console. Then try entering the command to run your program.