Determine triangular elements adjacend to the boundary elements

def get_ajd_bound(mesh):
    """
    Determine triangular elements adjacend to the boundary elements
    """
    print('Get elements adjacent to boundaries')
    boundary_elements = []
    str_adj_boundaries = ''
    # for boundary in mesh['elements']['1']:
    boundaries = mesh['boundaries']['12'] + mesh['boundaries']['11']
    for boundary in boundaries:
        # now find the triangle ('2') with two nodes equal to this boundary
        indices = [nr if (boundary[0] in x and boundary[1] in x) else np.nan
                   for (nr, x) in enumerate(mesh['elements']['2'])]
        indices = np.array(indices)[~np.isnan(indices)]
        if(len(indices) != 1):
            print('More than one neighbour found!')
        elif(len(indices) == 0):
            print('No neighbour found!')
        boundary_elements.append(indices[0])
        str_adj_boundaries += '{0}\n'.format(int(indices[0]) + 1)
    return str_adj_boundaries, boundary_elements