Example list of dicts:
[{'name': 'aly', 'age': '104'}, {'name': 'Not A name', 'age': '99'}]
Expected out = ['aly', '104', 'Not A name', '99']
Any help will be much appreciated.
Thanks!
Advertisement
Answer
Try this in one line:
d = [{'name': 'aly', 'age': '104'}, {'name': 'Not A name', 'age': '99'}] [v for i in d for k,v in i.items()]
The result will be:
Out[1]: ['aly', '104', 'Not A name', '99']