I want to be able to convert a list of lists (which we can assume that the inner lists are all of equal length) into a justified table using a function.
So far I have tried the below but this doesnt justify the table.
I also need to understand what zip is doing? Can i always unpack when using *v?
Could i get an explanation of why I need to do *v to unpack out of the tuple instead of just using *Data in my code below?
def printTables(Data):
for v in zip(*Data):
print(*v)
printTables(tableData)
Input:
tableData = [['apples', 'oranges', 'cherries', 'banana'],
['Alice', 'Bob', 'Carol', 'David'],
['dogs', 'cats', 'moose', 'goose']]
Output:
apples Alice dogs
oranges Bob cats
cherries Carol moose
banana David goose