use a loop to create lists
Chris Angelico
rosuav at gmail.com
Thu Apr 11 09:22:41 EDT 2013
On Thu, Apr 11, 2013 at 10:57 PM, Thomas Goebel
<Thomas.Goebel at ohm-hochschule.de> wrote:
> [a for a in range(3)]
>
> will return a list
> [0, 1, 2]
Simplification possible: That's the same as:
list(range(3))
> f = {'list_' + str(n):[m for m in range(3)] for n in range(3)}
Meaning that this can be simplified too:
f = {'list_' + str(n):list(range(3)) for n in range(3)}
ChrisA
More information about the Python-list
mailing list