Can I build a dictonary with a list-comprehension?

spex66 spex66 at web.de
Fri Aug 31 09:48:05 EDT 2001


found in PLEAC (pleac.sourceforge.net)

dict = {}
LIST = [...] #What you want
[dict.update({x: 'spam'}) for x in LIST]

simple and effective
thx PLEAC project!

(=PA=)


"spex66" <spex66 at web.de> schrieb im Newsbeitrag
news:9mnpst$198$1 at news2.iabg.de...
> Hi there,
>
> I ask mysel, if there is a tricky (or simple) way to build a dictonary
with
> the list-comprehesion-style:
>
> [x for x in y]
>
> thanks for any hint
>
> Peter
> (=PA=)
>
>





More information about the Python-list mailing list