[Tutor] Problem with print

Steven D'Aprano steve at pearwood.info
Mon Dec 20 11:15:50 CET 2010


David Hutto wrote:
> On Sun, Dec 19, 2010 at 4:33 PM, Hugo Arts <hugo.yoshi at gmail.com> wrote:
>> 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

[...]

> Apparently so, but I'd like to see the full code to know what caused
> the error to point to print.

It is very common for an error in parentheses or brackets to lead to a 
syntax error on the following line.

 >>> compile("""
... x = 1
... y = (x+1/2
... z = 3
... """, "", "exec")
Traceback (most recent call last):
   File "<stdin>", line 5, in <module>
   File "", line 4
     z = 3
     ^
SyntaxError: invalid syntax


-- 
Steven



More information about the Tutor mailing list