return respective values when mutiple keys are passed in dictionary
Виталий Волков
hash.3g at gmail.com
Mon May 7 07:36:57 EDT 2012
You can try to use map(mydict.get, ('a', 'b', 'c')) and then make join
On May 7, 2012 2:33 PM, "Nikhil Verma" <varma.nikhil22 at gmail.com> wrote:
> HI All
>> I was clearing my concepts on dictionary and stuck in this problem.
> I have a dictionary which i have formed by using zip function on two list
> so that one list (which i have hardcoded) becomes the keys and the other
> list
> becomes its values.
>> Now i want to know how can i get the values of keys at once if i pass the
> keys in a dictionary.
>> Let say I have a dictionary
>> mydict = {'a':'apple' , 'b':'boy' ,'c' : 'cat', 'd':'duck','e':'egg'}
>> Now if i do :-
>> mydict.get('a')
> 'apple'
>> What i want is some i pass keys in get and in return i should have all the
> values of those keys which i pass.
>> ##################
> mydict.get('a','b','c') ###demo for what i want
> 'apple','boy','cat' ### Output i want
> #################
>> --
> Regards
> Nikhil Verma
> +91-958-273-3156
>>> --
> http://mail.python.org/mailman/listinfo/python-list
>>-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120507/2791f926/attachment-0001.html>
More information about the Python-list
mailing list