<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def gen_table(contents):
 """ creates a table given any set of columns """

    xlengths = []
    ylengths = []
    for column in contents:
        col_len = 0
        for entry in column:
            lines = entry.split('\n')
            for line in lines:
                col_len = max(len(line) + 2, col_len)
        xlengths.append(col_len)
    for i in range(len(contents[0])):
        ymax = 0
        for j in range(len(contents)):
            ymax = max(ymax, len(contents[j][i].split('\n')))
        ylengths.append(ymax)

    table_divider = '+' + ''.join(['-' * i + '+' for i in xlengths]) + '\n'
    table = table_divider
    for i in range(len(ylengths)):
        row = [column[i] for column in contents]
        row = [entry + '\n' * (ylengths[i]-len(entry.split('\n'))) for entry in row]
        row = [entry.split('\n') for entry in row]
        for j in range(ylengths[i]):
            k = 0
            for entry in row:
                width = xlengths[k]
                table += ''.join(['| {:{}}'.format(entry[j], width - 1)])
                k += 1
            table += '|\n'
        table += table_divider
    return table + '\n'