Best way to convert a list to a dictionary

Alex cut_me_out at hotmail.com
Wed May 3 13:11:15 EDT 2000


> I have a list where each element is another list with two elements.
> What is the best way to convert this to a dictionary?

It's hard to beat a for loop:

d = {}
for key, value in l:
    d[key] = value

Alex.



More information about the Python-list mailing list