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?

Mat
  • 202,337
  • 40
  • 393
  • 406
Jay Gatsby
  • 155
  • 1
  • 1
  • 4
  • 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!')`. – g.d.d.c Jul 20 '11 at 19:57

1 Answers1

20

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

print("Hello!")
Wooble
  • 87,717
  • 12
  • 108
  • 131
  • 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. – agf Jul 20 '11 at 20:09