list comprehensions value assignment syntax error

Inyeol Lee inyeol.lee at siimage.com
Wed Jan 8 01:40:36 CET 2003


On Tue, Jan 07, 2003 at 08:18:22PM +0100, Gerrit Holl wrote:
> Hi,
> 
> I am trying to assign to a list item using list comprehensions, but this
> raises a SyntaxError:
> 
> >>> [l[i] = chr(i) for i in range(256)]
>    File "<stdin>", line 1
>        [l[i] = chr(i) for i in range(256)]
> 	             ^
> 				 SyntaxError: invalid syntax
> 
> Why?

L = [chr(i) for i in range(256)]





More information about the Python-list mailing list