/ Published in: Python
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
''' Use sum() on the outer list and prime it with an empty list, []. Python will concatenate the inner lists, producing a flattened list. More alternative on the URL ''' alist = [['a', 'b'], ['c'], ['d', 'e', 'f']] print sum(alist, []) -output- ['a', 'b', 'c', 'd', 'e', 'f']