SV: Best way to convert a list to a dictionary

Lars Lundstedt lars.lundstedt at telia.com
Thu May 4 12:35:50 EDT 2000


Thank you!

Justin Sheehy <dworkin at ccs.neu.edu> skrev i
diskussionsgruppsmeddelandet:vndn1m7blnq.fsf at camelot-new.ccs.neu.edu...
> "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