[int(''.join(map(str, [x] + list(ys) + [z] + list(ys)[::-1] + [x] if k % 2 else
    [x] + list(ys) + list(ys)[::-1] + [x]))) for x in range(1, 10) for ys in
    itertools.permutations(list(range(10)), k / 2 - 1) for z in (list(range(10)) if k %
    2 else (None,))]
Generate list of all palindromic numbers of 3 digits in python