Format list of list sub elements keeping structure.

Sayth Renshaw flebber.crue at gmail.com
Tue Jul 24 00:15:56 EDT 2018


I am very close to the end result. I now have it as

Output
[   ['[glossary]'],
    ['[glossary]', '[title]'],
    ['[glossary]', '[GlossDiv]'],
    ['[glossary]', '[GlossDiv]', '[title]'],
    ['[glossary]', '[GlossDiv]', '[GlossList]'],
    ['[glossary]', '[GlossDiv]', '[GlossList]', '[GlossEntry]'],
.........]

I used.

elements = [['[{0}]'.format(element) for element in elements]for elements in data]

Is there a good way to strip the ', ' and make the list a list of 1 element lists? Thoughts on achieving this?

So

[   ['[glossary]'],
    ['[glossary][title]'],
....]

Cheers

Sayth




More information about the Python-list mailing list