[Tutor] Problem with print

Hugo Arts hugo.yoshi at gmail.com
Sun Dec 19 22:33:47 CET 2010


On Sun, Dec 19, 2010 at 10:11 PM, Sander Sweers <sander.sweers at gmail.com> wrote:
> On 19 December 2010 21:54, jtl999 <jacksmoo111 at gmail.com> wrote:
>>  File "GettingStarted.py", line 91
>>    print ("Lesson Two")
>>        ^
>> SyntaxError: invalid syntax
>>
>> Python 2.6.5
>
> You are using a howto for python version 3.X but you are using python
> 2.X. In python 3 the print statement was changed to a function.
>
> Python 2.X
> print "Lesson Two"
>
> Python 3.X
> print("Lesson Two")
>
> Either find a version of the howto for 2 or install python 3.
>

Alex is right, David and Sander judged too quickly:

Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Lesson Two")
Lesson Two
>>> print("a", "b")
('a', 'b')

Note the python version? It works. The parentheses are just
parentheses, not a function call. But it still works. The actual error
is likely on the line before the print statement.

Hugo


More information about the Tutor mailing list