Re: For specific keys , extract non empty values in a dictionary

2018-06-17 Thread Peter Otten
Dennis Lee Bieber wrote: > On Sun, 17 Jun 2018 17:37:25 +0100, MRAB > declaimed the following: > >>On 2018-06-17 15:47, Ganesh Pal wrote: >>> {k: o_num[k] for k in wanted & o_num.keys() if o_num[k] is not >>> {None} >>> >>> Thanks peter this looks better , except that I will need

Re: For specific keys , extract non empty values in a dictionary

2018-06-17 Thread MRAB
On 2018-06-17 15:47, Ganesh Pal wrote: >>> {k: o_num[k] for k in wanted & o_num.keys() if o_num[k] is not None} Thanks peter this looks better , except that I will need to use the logial 'and' operator or else I will get a TypeError {k: o_num[k] for k in wanted & o_num.keys() if o_num[k]

Re: For specific keys , extract non empty values in a dictionary

2018-06-17 Thread Ganesh Pal
> >>> {k: o_num[k] for k in wanted & o_num.keys() if o_num[k] is not None} Thanks peter this looks better , except that I will need to use the logial 'and' operator or else I will get a TypeError >>> {k: o_num[k] for k in wanted & o_num.keys() if o_num[k] is not None} TypeError: unsupported

Re: For specific keys , extract non empty values in a dictionary

2018-06-16 Thread Peter Otten
Ganesh Pal wrote: > *How do I check few specific/selected keys in a dictionary and extract > their values if they are not empty* You mean not None. > o_num = {'one': 1, > 'three': 3, > 'bar': None, > 'five' : 5, > 'rum' : None, > 'seven' : Non

For specific keys , extract non empty values in a dictionary

2018-06-16 Thread Ganesh Pal
*How do I check few specific/selected keys in a dictionary and extract their values if they are not empty* *Example : Extract the values for key "one","three","seven" and "nine” if they are not empty* *Input :* *o_num = {'one': 1,* * 'three': 3,* * 'bar': None,* *