user1625016
user1625016

Reputation: 41

I do not understand this syntax error

I am doing the Python tutorial byte of python 120-1 pdf

Here are the instructions:

Start your choice of editor, enter the following program and save it as helloworld.py

Example 3.2. Using a Source File

#!/usr/bin/python
# Filename : helloworld.py
print 'Hello World'

(Source file: code/helloworld.py) Run this program by opening a shell (Linux terminal or DOS prompt) and entering the command python helloworld.py. If you are using IDLE, use the menu Edit -> Run Script or the keyboard shortcut Ctrl-F5. The output is as shown below.

Output

$ python helloworld.py

Hello World

I entered the program into text wrangler and saved it as helloworld.py

I then opened my terminal and entered python helloworld.py.

I received syntax error: invalid syntax

I then tried helloworld.py and also received syntax error: invalid syntax

Can anyone tell me where I went wrong?

Upvotes: 0

Views: 183

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798536

You're using 2.x documentation, but are running 3.x. Either downgrade Python, or find more recent material.

#!/usr/bin/python
# Filename : helloworld.py
print('Hello World')

Upvotes: 6

Related Questions