Fwd: use a loop to create lists
Franz Kelnreiter
kelnreiter at gmail.com
Thu Apr 11 10:33:41 EDT 2013
On Thu, Apr 11, 2013 at 3:43 PM, Thomas Goebel <
Thomas.Goebel at ohm-hochschule.de> wrote:
> ...
> > I get a syntax error, as I exepected (Python 2.6.4 (r264:75708, Oct 26
> > 2009, 08:23:19)).
>
> Sorry Franz,
>
> as you are using python 2.6 you have to use
>
> d1 = dict(('list_' + str(i), []) for i in range(3))
> d2 = dict(('list_' + str(i), [m for m in range(3)]) for i in range(3))
>
> like stated here:
>
> http://stackoverflow.com/questions/1747817/python-create-a-dictionary-with-list-comprehension
> --
>
Thank you, Thomas, for your last posting and your help, that makes
everything clear for me now!
All best, Franz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130411/37671188/attachment.html>
More information about the Python-list
mailing list