list 2 dict?

Stefan Sonnenberg-Carstens stefan.sonnenberg at pythonmeister.com
Sun Jan 2 08:40:53 EST 2011


Am 02.01.2011 14:18, schrieb Octavian Rasnita:
> l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b']
l = [1, 2, 3, 4, 5, 6, 7, 'a', 8, 'b']
dict(zip(l[0::2],l[1::2]))
{8: 'b', 1: 2, 3: 4, 5: 6, 7: 'a'}



More information about the Python-list mailing list