i have a code like below:
out={}
for each_val in values["data"]['values']:
if each_val['value'].strip() != '':
if 'frequency' in each_val:
out[each_val['value']] = each_val['frequency']
else:
out[each_val['value']] = None
i am trying to make it one line with dict comprehension but not able to do it with 2 if loops inside for loop. Below is the code I tried but getting warnings and errors
out = {each_val['value']: each_val['frequency'] if 'frequency' in each_val and if each_val['value'].strip() != '' else None for each_val in values["data"]['values']}