What's wrong with my for loop?

Paul Osman paul.osman at sympatico.ca
Tue Nov 5 19:16:56 EST 2002


On Tue, 5 Nov 2002, Mindy wrote:

> Hey, I got such errors in runing my small program. The
> attachment is my program named ld.stat.py and the
> following is the error:
>
> % ld.stat.py
>   File "ld.stat.py", line 23
>     for name in names
>                     ^
> SyntaxError: invalid syntax

that's because your line should read:

for name in names:

note the colon...

> As there are no {} working as the limitators of
> functions or blocks(as in C or Perl), what we can
> control this is only by indentation, right?

that is correct. Python uses whitespace to group statements.

>
> =====
> Cheers
> -Mindy

-- 
Paul Osman
posman at linux.ca
http://paul.codecipher.com





More information about the Python-list mailing list