There is a dict,
dlist = [{'Bilbo' : 'Ian', 'Frodo' : 'Elijah'}, {'Bilbo' : 'Martin', 'Thorin' : 'Richard'}]
And let k = 'Frodo'
I want to extract the value corresponding to k when it exists and make a list.
I wrote
value_list = [dlist[i][k] for i in range(len(dlist)) if k in dlist[i] else "NOT PRESENT"].
But computer says else
is wrong. I don't know why.