In [1]:
def convert_1d_to_2d(l, cols):
    return [l[i:i + cols] for i in range(0, len(l), cols)]

In [2]:
l = [0, 1, 2, 3, 4, 5]

In [3]:
print(convert_1d_to_2d(l, 2))


[[0, 1], [2, 3], [4, 5]]

In [4]:
print(convert_1d_to_2d(l, 3))


[[0, 1, 2], [3, 4, 5]]

In [5]:
print(convert_1d_to_2d(l, 4))


[[0, 1, 2, 3], [4, 5]]

In [6]:
def convert_1d_to_2d_rows(l, rows):
    return convert_1d_to_2d(l, len(l) // rows)

In [7]:
print(convert_1d_to_2d_rows(l, 2))


[[0, 1, 2], [3, 4, 5]]

In [8]:
print(convert_1d_to_2d_rows(l, 3))


[[0, 1], [2, 3], [4, 5]]

In [9]:
print(convert_1d_to_2d_rows(l, 4))


[[0], [1], [2], [3], [4], [5]]