list 2 dict?

Paul Rubin no.email at nospam.invalid
Tue Jan 4 00:33:46 EST 2011


"Octavian Rasnita" <orasnita at gmail.com> writes:
> If I want to create a dictionary from a list...
> l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b']

    dict(l[i:i+2] for i in xrange(0,len(l),2))

seems simplest to me.



More information about the Python-list mailing list