def grouper(n, iterable, fillvalue=None):
    """grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"""
return itertools.zip_longest(fillvalue=fillvalue, *([iter(iterable)] * n))

def format_table(L):
    result = []
for row in L:
    result.append('| ' + ', '.join(row) + ' |')
return '\n'.join(result)
L = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
L_in_rows = list(grouper(3, L, fillvalue=' '))
L_in_columns = zip(*L_in_rows)
print(format_table(L_in_columns))
Displaying a list of items vertically in a table instead of horizonally