[Tutor] a question in the Python Tutorial
Lloyd Kvam
pythonTutor at venix.com
Mon Sep 6 02:54:00 CEST 2004
I think you probably copied in a space before 2+2
Python syntax depends on the spaces at the beginning of each line to
control blocks of code, much like braces {} in C, Java, Perl, and many
other languages. So leading spaces mean that the line should be within
an outer-block of code. If the outer-block does not exist, then there
is a syntax error.
>>> 2+2
4
>>> 2+2
File "<stdin>", line 1
2+2
^
SyntaxError: invalid syntax
On Sun, 2004-09-05 at 20:27, W X Liu wrote:
> I am studying the Python Tutorial, but I met a problem, in the Python Tutorial
> 3.1.1
>
> there is a piece of code:
>
> >>> # This is a comment
> ... 2+2
> 4
>
> I copy them into the Python shell, but cannot run:
>
> >>> # This is a comment
> ... 2+2
> SyntaxError: invalid syntax
>
> So, anyone can help to tell me what's wrong?
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
--
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358
voice: 603-653-8139
fax: 320-210-3409 (changed Aug 26, 2004)
More information about the Tutor
mailing list