Best way to convert a list to a dictionary

Justin Sheehy dworkin at ccs.neu.edu
Wed May 3 13:15:05 EDT 2000


"Lars Lundstedt" <lars.lundstedt at telia.com> writes:

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

Something like this would probably be simplest:

d = {}
for k, v in your_list:
    d[k] = v

-Justin

 




More information about the Python-list mailing list