0

I have list like:

[1, 2, ['a', 'b', 'c',], 3]

How can I add a line in a table to insert values of sublist

['a', 'b', 'c',] 

in one cell of table. The values have to be under each other

Is there any other libs to handle this use case if prettyTable is not available?

for now i have following code:

table = PrettyTable(headers)
for line in lines:
        table.add_row(line)
print table

but sublist is displayed as list in the cell. I haven't found any information in prettyTable documentation about adding several items into one cell

Vindict
  • 121
  • 3

1 Answers1

0

Maybe it will be hellpufull for someone:

list

['a', 'b', 'c',] 

should be converted in such format

"\n".join(['a', 'b', 'c',]). 

And than new string has to replace sublist so final result has to be

[1, 2, 'a\nb\nc', 3]. 

In such way 3-rd element of the list will be displayed as three elements one under another while using prettyTable

Vindict
  • 121
  • 3