On 04/01/2011 05:33, Paul Rubin wrote:
"Octavian Rasnita"<orasn...@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.

Or:

    dict(zip(l[0 : : 2], l[1 : : 2]))
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to