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 trialJoel Price
13,711 PointsWhen 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.
1 Answer
Steven Parker
231,271 PointsIt 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.
Joel Price
13,711 PointsJoel Price
13,711 Pointsthe '^' is actually under the t in python shopping_list.py