Suzan Cioc
Suzan Cioc

Reputation: 30127

Python invalid syntax in print

Sorry I am not familar with Python...

It gives me the following error message

  File "gen_compile_files_list.py", line 36
    print 'java files:', n_src
                      ^
SyntaxError: invalid syntax

I.e. caret points to last quote. What's wrong with it?

OS Windows 7, Python version 3.2.2

Upvotes: 0

Views: 2670

Answers (3)

j13r
j13r

Reputation: 2671

print changed syntax between Python2 and Python3; it is now a function.

You would need to change:

 print 'java files:', n_src

to

 print('java files:', n_src)

Alternatively, you can try converting the code from Python2 to Python3 syntax with the 2to3 tool. Here is more information on the transition if you are interested. This way you can maintain a single code base that works on both versions.

As you are not familiar with python, try installing Python 2 instead and running the code with that.

Upvotes: 2

Andrew Jaffe
Andrew Jaffe

Reputation: 27107

print is a function in Python 3+. So:

print ('java files:', n_src)

Upvotes: 1

David Heffernan
David Heffernan

Reputation: 613451

On Python 3, print is a function. You need this:

print('java files:', n_src)

Upvotes: 4

Related Questions