Given the below, how can i get the animal, age and gender into each of the table cells please? Currently all the data ends up in one cell. Thanks
from rich.console import Console
from rich.table import Table
list = [['Cat', '7', 'Female'],
['Dog', '0.5', 'Male'],
['Guinea Pig', '5', 'Male']]
table1 = Table(show_header=True, header_style='bold')
table1.add_column('Animal')
table1.add_column('Age')
table1.add_column('Gender')
for row in zip(*list):
table1.add_row(' '.join(row))
console.print(table1)
Just use
*
to unpack the tuple and it should work fine.Note that
is equivalent to
While previously your approach was equivalent to