Howto find dict members from a list of keys

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Thu Mar 8 09:26:22 CET 2007


En Thu, 08 Mar 2007 05:20:20 -0300, Alexander Eisenhuth  
<newsuser at stacom-software.de> escribió:

> what algo do you use, when you want to find the dict values from d, with  
> members
> of l. Following example:
>
>  >>> d = {1:2,2:3,3:4,4:5,5:6,6:7,7:8,8:9,9:10}
>  >>> l = [7,8]
>  >>> found_dic_members = <yourCode>
>  >>> print found_dict_members
> [8,9]

found_dic_members = [d[key] for key in l]


-- 
Gabriel Genellina




More information about the Python-list mailing list