c = {x: '' for x in a}

Aurelio Martin Massoni amartin at traza-si.com
Fri Mar 7 11:41:40 CET 2003


"Hilbert" <hilbert at microsoft.com> escribió en el mensaje
news:v6gp1841qlpr51 at corp.supernews.com...
> Ok.
> This works:
>
> a = [1,2,3]
> b = [x for x in a]
>
> What's wrong with this one though? It would totally make sense to
me...
>
> a = [1,2,3]
> c = {x: '' for x in a}

Try this one :

c = dict( [ ( x, '' ) for x in a ] )







More information about the Python-list mailing list