I need my func to print out the following:
apples Alice dogs
oranges Bob cats
cherries Carol moose
banana David goose
all items are aligned to the right
and I have solution but it's kinda workaround, could you please help me to correct my solution?
tableData = [['apples', 'oranges', 'cherries', 'banana'],
['Alice', 'Bob', 'Carol', 'David'],
['dogs', 'cats', 'moose', 'goose']]
def printData(lst):
colWidths = [0] * len(tableData)
for a in range(len(tableData)):
colWidths[a] = len(max(tableData[a], key=len))
for i in range(len(lst[0])):
output = ''
for j in range(len(lst)):
output += (str(lst[j][i])).rjust(colWidths[0])
print(output)
print(printData(tableData))
apples Alice dogs
oranges Bob cats
cherries Carol moose
banana David goose