EXECing multiple lines.

Bjorn Pettersen BPettersen at NAREX.com
Mon Jun 11 15:45:28 EDT 2001


> From: Joonas Paalasmaa [mailto:joonas at olen.to]
> 
> What might be wrong when I get the following error?
> 
> >>> exec """for x in range(5):
>     print x"""
> Traceback (innermost last):
>   File "<pyshell#3>", line 1, in ?
>     exec """for x in range(5):
>   File "<string>", line 2
>     print x
>           ^
> SyntaxError: invalid syntax
> >>>

You need to indent the line "print x".

-- bjorn




More information about the Python-list mailing list