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
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]
> >>> {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
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
*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,*
*