How do I merge a list of lists?
[[\'A\', \'B\', \'C\'], [\'D\', \'E\', \'F\'], [\'G\', \'H\', \'I\']]
into
[\'A\', \'B\', \
Use itertools.chain:
>>> import itertools
>>> list(itertools.chain(*mylist))
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I']
Wrapping the elements in HTML can be done afterwards.
>>> ['' + x + ' ' for x in itertools.chain(*mylist)]
['A ', 'B ', 'C ', 'D ', 'E ', 'F ',
'G ', 'H ', 'I ']
Note that if you are trying to generate valid HTML you may also need to HTML escape some of the content in your strings.