14

I'm running pywin32 build 216.1 and am having trouble using the simple print function - for example:

>>> print 'Hello!'

should return:

Hello!

but instead I get:

Traceback (  File "<interactive input>", line 1
    print 'Hello!'
                      ^
SyntaxError: invalid syntax

It doesn't matter what I try and use with print, it gives me this same error. I am able to do other things just fine as long as they don't involve the use of the print function. Can anyone help?

1
  • 2
    What version of Python are you running? In 2.x print is a statement and can be used as print 'Hello!'. In 3.x it is a function and should be called as print('Hello!'). Commented Jul 20, 2011 at 19:57

1 Answer 1

20

In Python 3, print is a function, not a statement. Call it like:

print("Hello!")
Sign up to request clarification or add additional context in comments.

1 Comment

Jay, pywin32 is not a version of Python, it's just the GUI and editor. The underlying interpreter is probably Python 3.2.0 or 3.2.1 if you just downloaded it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.