With a list comprehension like this, it is possible to extract a specific value from a key in a list of dictionaries:
ke = [d['_text'] for d in ls if '_text' in d]
Is it possible to extract two values at a time and store them as a tuple with one list comprhension?
So something like this:
ke = [(d['_text'] + e['url']) for (d,e) in ls if '_text', 'url' in d,e]
EDIT: Excuse me for not posting an example:
ls =[{'_text': 'hello', 'url': 'xxx-444.html'}, {'_text': 'bye', 'url': 'xxx-222.html'}]
Desire output:
ke = [('hello', 'xxx-444.html'), ('bye', 'xxx-222.html')]