I have the following code to generate a table using PrettyTable:
from prettytable import PrettyTable
# columns names
columns = ["Characters", "FFF", "Job"]
# lists
lista1 = ["Leanord", "Penny", "Howard", "Bernadette", "Sheldon", "Raj"]
lista2 = ["X", "X", "X", "X", "X", "X", "X"]
lista3 = ["B", "C", "A", "D", "A", "B", "B"]
# init table
myTable = PrettyTable()
# Add data
myTable.add_column(columns[0], [item for item in lista1])
myTable.add_column(columns[1], [item for item in lista2])
myTable.add_column(columns[2], [item for item in lista3])
print(myTable)
And this is the output:
However, what I really want is to create a table with different column sizes (my lists have different lengths). In other words, this is my desired output:
I tried using the code above, however, I'm getting the following error: Exception: Column length 7 does not match number of rows 6!
I would really appreciate your help!!!