Look here for more information on what's new in python 3, relating to the print
function. Functions are characterized by having open and close parentheses:
E.g.
str.split()
list.reverse()
list.insert(0, 'hi')
In python 2, the following syntax would be fine:
$ python2
Python 2.7.6 (v2.7.6:3a1db0d2747e, Nov 10 2013, 00:42:54)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> num = 78
>>> print 'The number is %d' %(num)
The number is 78
>>>
However, in python 3, because print
is a function, you need open and close parentheses:
$ python3
Python 3.4.0b2 (v3.4.0b2:ba32913eb13e, Jan 5 2014, 11:02:52)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> num = 78
>>> print 'The number is %d' %(num)
File "<stdin>", line 1
print 'The number is %d' %(num)
^
SyntaxError: invalid syntax
>>> print('The number is %d' %(num))
The number is 78
>>>
What you need to do is:
formatter="%r%r%r%r"
print(formatter % (1,2,3,4))