def _num_ln(keys, num):
    """Arranging buttons"""
    if type(keys[0]) is list:
        keys = keys[0]
    len_k = len(keys)
    num_of_lines = len_k // num
    lst, curr = [], 0
    for d in range(num_of_lines):
        temp_lst = []
        for e in range(curr, num + curr):
            temp_lst.append(keys[e])
        lst.append(temp_lst)
        curr += num
    lst.append(keys[len_k - len_k % num:])
    return lst
